-
Notifications
You must be signed in to change notification settings - Fork 746
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
Hold HeadTracker lock until persisting to disk #5084
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dapplion
changed the title
Fix head tracker drop order on un-ordered shutdown
Hold HeadTracker lock until persisting to disk
Jan 18, 2024
There's one smol clippy failure. Once that's fixed I think we can merge this for v4.6.0 |
michaelsproul
added
waiting-on-author
The reviewer has suggested changes and awaits thier implementation.
database
v4.6.0
ETA Q1 2024
labels
Jan 19, 2024
|
||
// Hold a lock to head_tracker until it has been persisted to disk. Otherwise there's a race | ||
// condition with the pruning thread which can result in a block present in the head tracker | ||
// but absent in the DB. This inconsistency halts pruning and dramastically increases disk |
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.
yesssss for dramastically
paulhauner
added a commit
that referenced
this pull request
Jan 19, 2024
Squashed commit of the following: commit d73a2b3 Author: dapplion <35266934+dapplion@users.noreply.github.com> Date: Fri Jan 19 09:12:48 2024 +0800 lint commit 5b5a304 Author: Michael Sproul <michael@sigmaprime.io> Date: Tue Jan 16 16:10:28 2024 +1100 Fix head tracker drop order on un-ordered shutdown
dapplion
added
ready-for-review
The code is ready for review
and removed
waiting-on-author
The reviewer has suggested changes and awaits thier implementation.
labels
Jan 19, 2024
michaelsproul
approved these changes
Jan 22, 2024
michaelsproul
added
ready-for-merge
This PR is ready to merge.
and removed
ready-for-review
The code is ready for review
labels
Jan 22, 2024
danielrachi1
pushed a commit
to danielrachi1/lighthouse
that referenced
this pull request
Feb 14, 2024
* Fix head tracker drop order on un-ordered shutdown * lint --------- Co-authored-by: Michael Sproul <michael@sigmaprime.io>
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Addressed
Closes #4773
Implements the fix from #5073
Proposed Changes
When persisting the head tracker in the context of the BeaconChain, hold its read lock until it has been written to disk. Otherwise there's a race condition with the pruning thread that can cause it to persist stale data.
Additional Info
Linking another line of concern for this issue, pruning routine dropping the lock before writing the serialised head_tracker data to disk.
lighthouse/beacon_node/beacon_chain/src/migrate.rs
Lines 695 to 705 in f22e5b0
As long as pruning does not run twice concurrently the only other possible mutation is the BeaconNode importing a block. We have observed that happening during a unwind sequence, so it's definitely possible. In that case we can end-up with a block that exists in the DB but not in the HeadTracker. This can slightly pollute the DB but not break pruning.