go/store/nbs: Fix a race between the journal persister and PruneTableFiles. - #11312
Merged
Conversation
…Files. Racing GC and/or crashing at an inopportune time could result in "root hash not found" or a panic on attempting to remove a missing journal file.
Contributor
Contributor
|
@reltuk DOLT
|
Contributor
Contributor
…ve this test case test running SIGKILL against the process as well.
Contributor
|
@reltuk DOLT
|
Contributor
|
Could you add a more detailed description to the PR, explaining why the race necessitates the creating the concept of a "protected journal file", and outlining a sequence of events that previously would have resulted in data corruption and why it wouldn't happen under the new PR? |
nicktobey
approved these changes
Jul 17, 2026
| // the NomsBlockStore mutex, while PruneTableFiles runs under the persister's | ||
| // pruneMu; before the fix these disjoint lock domains let a prune delete a live | ||
| // journal file, and left ChunkJournal.PruneTableFiles reading j.wr without | ||
| // synchronization. Run under `-race` this reliably catches the unsynchronized |
Contributor
There was a problem hiding this comment.
If this reliably catches the race condition as the comment says, why does it run 300 iterations? Do we use a "race" flag in our tests?
This file contains hidden or 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
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.
When PruneTableFiles runs, it is willing to delete the journal file if there is no longer a reference to it in the manifest. This can race with bootstrapJournal making a new journal file. The journal file can be on disk, and seen by PruneTableFiles and thus selected for removal, before the journal has been added to the chunk store proper.
This change makes the journal writer participate in the retained files machinery, same as the table file persister, so that the journal is correctly considered not-safe-for-delete-by-PruneTableFiles before it is ever created on disk and potentially selected for deletion by PruneTableFiles.