@@ -121,6 +121,9 @@ func redeemWriteMarker(md *markerData) error {
121
121
shouldRollback := false
122
122
start := time .Now ()
123
123
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 ()
124
127
defer func () {
125
128
if shouldRollback {
126
129
if rollbackErr := db .Rollback ().Error ; rollbackErr != nil {
@@ -130,14 +133,10 @@ func redeemWriteMarker(md *markerData) error {
130
133
}
131
134
132
135
} else {
133
- go deleteMarkerData (allocationID )
136
+ deleteMarkerData (allocationID )
134
137
}
135
138
}()
136
139
137
- allocMu := lock .GetMutex (allocation.Allocation {}.TableName (), allocationID )
138
- allocMu .RLock ()
139
- defer allocMu .RUnlock ()
140
-
141
140
alloc , err := allocation .Repo .GetAllocationFromDB (ctx , allocationID )
142
141
if err != nil {
143
142
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 {
150
149
151
150
if alloc .Finalized {
152
151
logging .Logger .Info ("Allocation is finalized. Skipping redeeming the write marker." , zap .Any ("allocation" , allocationID ))
153
- go deleteMarkerData (allocationID )
152
+ deleteMarkerData (allocationID )
154
153
shouldRollback = true
155
154
return nil
156
155
}
@@ -174,7 +173,7 @@ func redeemWriteMarker(md *markerData) error {
174
173
if retryRedeem (err .Error ()) {
175
174
go tryAgain (md )
176
175
} else {
177
- go deleteMarkerData (allocationID )
176
+ deleteMarkerData (allocationID )
178
177
}
179
178
shouldRollback = true
180
179
return err
0 commit comments