Skip to content

Commit 72454ce

Browse files
committed
run delete in same routine
1 parent 406e4ea commit 72454ce

File tree

1 file changed

+6
-7
lines changed
  • code/go/0chain.net/blobbercore/writemarker

1 file changed

+6
-7
lines changed

code/go/0chain.net/blobbercore/writemarker/worker.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ func redeemWriteMarker(md *markerData) error {
121121
shouldRollback := false
122122
start := time.Now()
123123
logging.Logger.Info("redeeming_write_marker", zap.String("allocationID", allocationID))
124+
allocMu := lock.GetMutex(allocation.Allocation{}.TableName(), allocationID)
125+
allocMu.RLock()
126+
defer allocMu.RUnlock()
124127
defer func() {
125128
if shouldRollback {
126129
if rollbackErr := db.Rollback().Error; rollbackErr != nil {
@@ -130,14 +133,10 @@ func redeemWriteMarker(md *markerData) error {
130133
}
131134

132135
} else {
133-
go deleteMarkerData(allocationID)
136+
deleteMarkerData(allocationID)
134137
}
135138
}()
136139

137-
allocMu := lock.GetMutex(allocation.Allocation{}.TableName(), allocationID)
138-
allocMu.RLock()
139-
defer allocMu.RUnlock()
140-
141140
alloc, err := allocation.Repo.GetAllocationFromDB(ctx, allocationID)
142141
if err != nil {
143142
logging.Logger.Error("Error redeeming the write marker.", zap.Any("allocation", allocationID), zap.Any("wm", allocationID), zap.Any("error", err))
@@ -150,7 +149,7 @@ func redeemWriteMarker(md *markerData) error {
150149

151150
if alloc.Finalized {
152151
logging.Logger.Info("Allocation is finalized. Skipping redeeming the write marker.", zap.Any("allocation", allocationID))
153-
go deleteMarkerData(allocationID)
152+
deleteMarkerData(allocationID)
154153
shouldRollback = true
155154
return nil
156155
}
@@ -174,7 +173,7 @@ func redeemWriteMarker(md *markerData) error {
174173
if retryRedeem(err.Error()) {
175174
go tryAgain(md)
176175
} else {
177-
go deleteMarkerData(allocationID)
176+
deleteMarkerData(allocationID)
178177
}
179178
shouldRollback = true
180179
return err

0 commit comments

Comments
 (0)