Skip to content

Commit cd4015a

Browse files
Add lock around catchpointsMu to avoid race condition (#3944)
While upgrading to golang 1.17.9 a couple of race conditions have been detected during E2E tests. This fixes catchpoint label assignment.
1 parent c0372a3 commit cd4015a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

ledger/catchpointtracker.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -413,20 +413,18 @@ func (ct *catchpointTracker) postCommit(ctx context.Context, dcc *deferredCommit
413413
}
414414
}
415415

416+
ct.catchpointsMu.Lock()
417+
ct.roundDigest = ct.roundDigest[dcc.offset:]
416418
if dcc.isCatchpointRound && dcc.catchpointLabel != "" {
417419
ct.lastCatchpointLabel = dcc.catchpointLabel
418420
}
421+
ct.catchpointsMu.Unlock()
422+
419423
dcc.updatingBalancesDuration = time.Since(dcc.flushTime)
420424

421425
if dcc.updateStats {
422426
dcc.stats.MemoryUpdatesDuration = time.Duration(time.Now().UnixNano())
423427
}
424-
425-
ct.catchpointsMu.Lock()
426-
427-
ct.roundDigest = ct.roundDigest[dcc.offset:]
428-
429-
ct.catchpointsMu.Unlock()
430428
}
431429

432430
func (ct *catchpointTracker) postCommitUnlocked(ctx context.Context, dcc *deferredCommitContext) {

0 commit comments

Comments
 (0)