Repository navigation
fix(journal): keep the replay head at the end of the data area - #77
Merged
Merged
Conversation
When the last replayed record ended exactly at the end of the data area, replay recorded its progress as head 0 with the tail still at the end, which reads as a full ring. If recovery then stopped before resetting the journal, after losing its lease or in a crash, the next recovery scanned the whole ring from 0 and replayed records again. The head now stays at the end, so head == tail and the journal reads as empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The shepherd found this in the #76 review. When the last record replay finished ended exactly at the end of the data area,
scanJournal'sadvancerecorded head 0 with the tail still at the end. The superblock reads that as a full ring. If recovery then stopped beforeReset(a lost lease inRecoverChecked, or a crash), the next recovery scanned the whole ring from 0 and replayed records it had already applied. The head now stays at the end (next > sizeinstead of>=), so head == tail reads as empty.readSuperblockalready accepts a head equal to the data area size, and the checkpoint code handles it.TestStoppedReplayAtEndLeavesJournalEmptysets up a pending record that ends at the end of the data area. It loses the recovery lease right after replaying that record, then runs recovery again: the second run must replay nothing.Tested on .66: the new test fails on main's
recovery.go("replayed [2] again") and passes on this branch 10 times with-race, along with the journal, fsck and goclusterfs packages. Rebased onto main after #75 (test-only change, no overlap). golangci-lint v2: 0 issues.🤖 Generated with Claude Code