Skip to content

Commit

Permalink
fix: fix GC
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgao001 committed Mar 28, 2024
1 parent 7372acc commit 8d1cabb
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions modular/executor/execute_gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,12 @@ func (e *ExecuteModular) gcZombiePieceFromIntegrityMeta(ctx context.Context, tas
if strings.Contains(err.Error(), "no such object from metadata") {
// If deletion is possible, has integrity hash, lacks object info, perform a chain check, and verify against the chain.
if objInfoFromChain, err = e.baseApp.Consensus().QueryObjectInfoByID(ctx, strconv.FormatUint(objID, 10)); err != nil {
if strings.Contains(err.Error(), "No such object") {
// 1) This object does not exist on the chain
e.gcWorker.deleteObjectPiecesAndIntegrityMeta(ctx, integrityObject, objInfoFromChain.Version)
}
log.Errorf("failed to get object info from chain", "error", err)
continue
} else {
// 2) query metadata error, but chain has the object info, gvg primary sp should have integrity meta
if e.gcWorker.checkGVGMatchSP(ctx, objInfoFromChain, integrityObject.RedundancyIndex) == ErrInvalidRedundancyIndex {
e.gcWorker.deleteObjectPiecesAndIntegrityMeta(ctx, integrityObject, objInfoFromMetaData.Version)
e.gcWorker.deleteObjectPiecesAndIntegrityMeta(ctx, integrityObject, objInfoFromChain.Version)
}
continue
}
Expand Down Expand Up @@ -738,6 +736,25 @@ func (e *ExecuteModular) gcStaleVersionObjectFromShadowIntegrityMeta(ctx context
break
}
}
// it might be already GC by the GCZombie job
if staleIntegrityMeta == nil {
integrityMeta := &spdb.IntegrityMeta{
ObjectID: task.GetObjectId(),
RedundancyIndex: task.GetRedundancyIndex(),
IntegrityChecksum: task.GetIntegrityChecksum(),
PieceChecksumList: task.GetPieceChecksumList(),
}
err = e.baseApp.GfSpDB().SetObjectIntegrity(integrityMeta)
if err != nil {
return err
}
err = e.baseApp.GfSpDB().DeleteShadowObjectIntegrity(task.GetObjectId(), task.GetRedundancyIndex())
if err != nil {
log.Errorw("failed to delete shadow object integrity meta", "object_id", task.GetObjectId())
return err
}
return nil
}
for segIdx := uint32(0); segIdx < uint32(len(staleIntegrityMeta.PieceChecksumList)); segIdx++ {
pieceKey := e.baseApp.PieceOp().ECPieceKey(task.GetObjectId(), segIdx, uint32(staleIntegrityMeta.RedundancyIndex), task.GetVersion()-1)
err = e.baseApp.PieceStore().DeletePiece(ctx, pieceKey)
Expand Down

0 comments on commit 8d1cabb

Please sign in to comment.