Skip to content

fix(journal): keep the replay head at the end of the data area - #77

Merged
mattmattox merged 2 commits into
mainfrom
claude/journal-advance-at-end
Nov 12, 2026
Merged

mattmattox merged 2 commits into
mainfrom
claude/journal-advance-at-end

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

The shepherd found this in the #76 review. When the last record replay finished ended exactly at the end of the data area, scanJournal's advance recorded head 0 with the tail still at the end. The superblock reads that as a full ring. If recovery then stopped before Reset (a lost lease in RecoverChecked, 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 > size instead of >=), so head == tail reads as empty. readSuperblock already accepts a head equal to the data area size, and the checkpoint code handles it.

TestStoppedReplayAtEndLeavesJournalEmpty sets 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

mattmattox and others added 2 commits November 12, 2026 06:19
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>
@mattmattox
mattmattox merged commit 5c7c6c4 into main Nov 12, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant