Skip to content

Commit

Permalink
fix: fix the get object status from bundle service as it latency too …
Browse files Browse the repository at this point in the history
…high
  • Loading branch information
alexgao001 committed Aug 6, 2024
1 parent 6566e82 commit 18318ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion external/cmn/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ type QuotaInfo struct {
}

type ObjectInfo struct {
Checksums []string `json:"checksums"`
Checksums []string `json:"checksums"`
ObjectStatus string `json:"object_status"`
}

type GetObjectInfoResponse struct {
Expand Down
21 changes: 16 additions & 5 deletions syncer/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func (s *BlobSyncer) verify() error {
if err != nil {
return err
}

verifyBlockID := verifyBlock.Slot
// validate the bundle info at the start slot of a bundle
if verifyBlockID == bundleStartBlockID || !s.DetailedIntegrityCheckEnabled() {
Expand Down Expand Up @@ -92,13 +91,25 @@ func (s *BlobSyncer) verify() error {
}
return nil
}

// the bundle is not sealed yet
if bundleInfo.Status == BundleStatusFinalized || bundleInfo.Status == BundleStatusCreatedOnChain {
if bundle.CreatedTime > 0 && time.Now().Unix()-bundle.CreatedTime > s.config.GetReUploadBundleThresh() {
logging.Logger.Infof("the bundle %s is not sealed and exceed the re-upload threshold %d ", bundleName, s.config.GetReUploadBundleThresh())
return s.reUploadBundle(bundleName)
// get the object meta from chain
objectMeta, err := s.chainClient.GetObjectMeta(context.Background(), s.getBucketName(), bundleName)
if err != nil {
logging.Logger.Errorf("failed to get object meta from chain, bundleName=%s", bundleName)
return err
}
// check the object info from chain to make sure it is not be sealed
// if it is not be sealed, re-upload it
if objectMeta.ObjectStatus != "OBJECT_STATUS_SEALED" {
if bundle.CreatedTime > 0 && time.Now().Unix()-bundle.CreatedTime > s.config.GetReUploadBundleThresh() {
logging.Logger.Infof("the bundle %s is not sealed and exceed the re-upload threshold %d ", bundleName, s.config.GetReUploadBundleThresh())
return s.reUploadBundle(bundleName)
}
logging.Logger.Info("the bundle is not sealed yet, bundleName=%s, status = %d", bundleName, bundleInfo.Status)
return nil
}
return nil
}
}

Expand Down

0 comments on commit 18318ed

Please sign in to comment.