Skip to content

fix(journal): bound the recovery scan by the bytes between head and tail - #76

Merged
mattmattox merged 2 commits into
mainfrom
claude/journal-scan-bound
Nov 12, 2026
Merged

mattmattox merged 2 commits into
mainfrom
claude/journal-scan-bound

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

Both journal recovery scans ran for pos != tail. If the tail is a position no record boundary reaches, the scan goes around the ring through stale records from earlier laps and never stops, replaying old transactions as it goes. readSuperblock already refuses an on-disk head or tail that is outside the data area or not sector-aligned (#34), so this is defense in depth. The scans now stop after reading the bytes between head and tail, so every scan ends and reads each record at most once. With valid pointers they behave as before, including a tail at the very end of the data area (#65).

TestScanStopsAtUnreachableTail fills the ring a full lap, commits two pending intents, and moves the in-memory tail 512 bytes past a record boundary. On main's recovery.go the scan was still running after 10 s. On this branch it replays the two intents once each.

Results: the new test passes 10 out of 10 with -race, along with the full-ring and tail-at-end tests. All unit tests pass with -race, lint is clean, and parity passes.

🤖 Generated with Claude Code

mattmattox and others added 2 commits November 12, 2026 05:02
Both recovery scans ran until the position equaled the tail. A tail no
record boundary reaches, such as a corrupt in-memory pointer, sent them
around the ring through stale records forever, replaying old
transactions on the way. They now stop after reading the bytes from head
to tail, so every scan ends and reads each record at most once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattmattox
mattmattox merged commit 0c801f1 into main Nov 12, 2026
13 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