Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add check when initializing processing state #744

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bxue-l2
Copy link
Contributor

@bxue-l2 bxue-l2 commented Sep 4, 2024

This PR adds checks in StoreBlob, called by apiserver when first receiving a blob

This PR inserts a s.GetBlobMetadata before uploading the blob on S3 and setting blobMetaData. The expected behaviors is that such metadata should not ever exists. If it does, return err

@bxue-l2 bxue-l2 requested review from jianoaix, mooselumph and ian-shim and removed request for jianoaix September 4, 2024 16:23
@@ -90,6 +92,12 @@ func (s *SharedBlobStore) StoreBlob(ctx context.Context, blob *core.Blob, reques
metadataKey.BlobHash = blobHash
metadataKey.MetadataHash = metadataHash

refreshedMetadata, err := s.GetBlobMetadata(ctx, metadataKey)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if there is a 500 error from dynamo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I should just check if refreshedMetadata is nil or not

@@ -21,6 +21,8 @@ const (

var errProcessingToDispersing = errors.New("blob transit to dispersing from non processing")

var errProcessingInitialization = errors.New("blob status initialization")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call this not meeting the precondition

refreshedMetadata, err := s.GetBlobMetadata(ctx, metadataKey)
if !errors.Is(err, disperser.ErrMetadataNotFound) {
s.logger.Error("error intentionally get blob status before creation", "err", err, "status", refreshedMetadata.BlobStatus, "metadataKey", refreshedMetadata.GetBlobKey().String())
return metadataKey, errProcessingInitialization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the gRPC error code that will be returned to end user from here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be this

api.NewInternalError("failed to store blob, please try again later")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense, because later users requestTime will be different

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good point: How would users store the same metadataKey twice? Even if sending the same blob, it'll result in different metadataKey, so there is no overwrite.

@@ -21,6 +21,8 @@ const (

var errProcessingToDispersing = errors.New("blob transit to dispersing from non processing")

var errProcessingMeetingPrecondition = errors.New("blob not meeting precondition to processing")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errProcessingFailedPrecondition("blob metadata already exists....")?

refreshedMetadata, err := s.GetBlobMetadata(ctx, metadataKey)

// the only safe condition:
// err is disperser.ErrMetadataNotFound && refreshedMetadata is nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me there are 2 failure cases:

  • Failed to get metadata (due to errors other than Not Found): this is an INTERNAL error
  • Got the metadata: this is FAILED_PRECONDITION error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants