Skip to content

fix(journal): replay writes an inode only if nothing wrote it since the read - #132

Merged
mattmattox merged 1 commit into
mainfrom
claude/replay-write-if-unchanged
Nov 14, 2026
Merged

mattmattox merged 1 commit into
mainfrom
claude/replay-write-if-unchanged

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

Follow-up to the lock-exclusion audit. Exclusive locks only keep nodes apart, so goroutines on the replaying node could change an inode between the replay's unlocked read and its write, and the replay overwrote that change. updateExtents now uses WriteIfUnchanged with the generation it read. On a conflict it re-reads, and the #80 generation check skips the record.

  • TestReplayKeepsInodeWrittenDuringIt fails when Write is put back.
  • Adds a doc line to lock.Acquire: exclusive means per node.
  • No new dir test: TestSameNodeEditsKeepEveryEntry (perf(dir): answer lookups from an in-memory directory index #127) already fails 10/10 without LockDir.
  • SFB: -sfb is ignored, and no production code builds an sfb.Manager. freeSFBSlot is still reachable through unlink or migration of legacy files. A same-node race there can only lose a slot bit, and nothing else reads those bits; fsck reclaims containers by inode references.

Tested on .68: journal, lock, inode and dir unit tests; -race on journal; replay, failover and crash integration tests; lint clean.

🤖 Generated with Claude Code

…he read

A replay of a failed node's journal read the inode outside any lock and then
wrote it back unconditionally, so a same-node change made in between (the
node's goroutines join the exclusive lock the replay holds) was lost. The
replay now writes with WriteIfUnchanged on the generation it read; on a
conflict it re-reads and the generation check skips the record.

Also documents that an exclusive lock is exclusive per node only.

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