Skip to content

Commit

Permalink
Add lock around catchpointsMu to avoid race condition (#3944)
Browse files Browse the repository at this point in the history
While upgrading to golang 1.17.9 a couple of race conditions have been detected during E2E tests.
This fixes catchpoint label assignment.
  • Loading branch information
Eric-Warehime committed May 3, 2022
1 parent c0372a3 commit cd4015a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ledger/catchpointtracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,20 +413,18 @@ func (ct *catchpointTracker) postCommit(ctx context.Context, dcc *deferredCommit
}
}

ct.catchpointsMu.Lock()
ct.roundDigest = ct.roundDigest[dcc.offset:]
if dcc.isCatchpointRound && dcc.catchpointLabel != "" {
ct.lastCatchpointLabel = dcc.catchpointLabel
}
ct.catchpointsMu.Unlock()

dcc.updatingBalancesDuration = time.Since(dcc.flushTime)

if dcc.updateStats {
dcc.stats.MemoryUpdatesDuration = time.Duration(time.Now().UnixNano())
}

ct.catchpointsMu.Lock()

ct.roundDigest = ct.roundDigest[dcc.offset:]

ct.catchpointsMu.Unlock()
}

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

0 comments on commit cd4015a

Please sign in to comment.