-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
race condition: Add lock around catchpointsMu to avoid race condition #3944
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3944 +/- ##
=======================================
Coverage 49.97% 49.98%
=======================================
Files 400 400
Lines 68633 68635 +2
=======================================
+ Hits 34301 34305 +4
- Misses 30630 30631 +1
+ Partials 3702 3699 -3
Continue to review full report at Codecov.
|
ledger/catchpointtracker.go
Outdated
@@ -414,7 +414,9 @@ func (ct *catchpointTracker) postCommit(ctx context.Context, dcc *deferredCommit | |||
} | |||
|
|||
if dcc.isCatchpointRound && dcc.catchpointLabel != "" { | |||
ct.catchpointsMu.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This same lock is taken to update ct.roundDigest below, @algorandskiy do you think both ct.roundDigest and ct.lastCatchpointLabel need to be updated in the same locked section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this is not necessary since we generate it every 10k rounds, and not every round.
But for consistency I agree, it is better to move this if statement under the lock below.
@Eric-Warehime could you please do that?
@algorandskiy for historical purposes I looked it up in an old release before the catchpointtracker was introduced, like 3.0.1, and au.lastCatchpointLabel is updated just before au.accountsMu.Lock() too https://github.com/algorand/go-algorand/blob/v3.0.1-stable/ledger/acctupdates.go#L2265 |
8052cb4
to
955397c
Compare
955397c
to
6d5e86e
Compare
FYI, |
Summary
While upgrading to golang 1.17.9 I've run into a couple of race conditions which have been detected during E2E tests. This fixes one of them during which a write happens at https://github.com/algorand/go-algorand/blob/master/ledger/catchpointtracker.go#L417 and a read happens at https://github.com/algorand/go-algorand/blob/master/ledger/catchpointtracker.go#L173
Test Plan
e2e tests