Skip to content

Commit 257abf3

Browse files
authored
Merge pull request #1411 from 0chain/fix/check-set
Check set commit marker
2 parents 90de0ab + a10f8c1 commit 257abf3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

code/go/0chain.net/blobbercore/handler/handler_common.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,12 @@ func WithStatusConnectionForWM(handler common.StatusCodeResponderF) common.Statu
128128

129129
mutex := lock.GetMutex(allocation.Allocation{}.TableName(), allocationID)
130130
Logger.Info("Locking allocation", zap.String("allocation_id", allocationID))
131+
wmSet := writemarker.SetCommittingMarker(allocationID, true)
132+
if !wmSet {
133+
return nil, http.StatusBadRequest, common.NewError("pending_markers", "Committing marker set failed")
134+
}
131135
mutex.Lock()
132136
defer mutex.Unlock()
133-
writemarker.SetCommittingMarker(allocationID, true)
134137
tx := GetMetaDataStore().GetTransaction(ctx)
135138
resp, statusCode, err = handler(ctx, r)
136139

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ type markerData struct {
3333
inCommit bool // if new write marker is being committed
3434
}
3535

36-
func SetCommittingMarker(allocationID string, committing bool) {
36+
func SetCommittingMarker(allocationID string, committing bool) bool {
3737
markerDataMut.Lock()
3838
defer markerDataMut.Unlock()
3939
if data, ok := markerDataMap[allocationID]; ok {
40+
if data.processing {
41+
return false
42+
}
4043
data.inCommit = committing
4144
}
45+
return true
4246
}
4347

4448
func SaveMarkerData(allocationID string, timestamp common.Timestamp, chainLength int) {

0 commit comments

Comments
 (0)