Skip to content

fix(journal): refuse to mount over a damaged journal slot - #34

Merged
mattmattox merged 2 commits into
mainfrom
fix-journal-damaged-slot
Oct 24, 2026
Merged

mattmattox merged 2 commits into
mainfrom
fix-journal-damaged-slot

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

From the #10 review. A journal slot whose header had a bad checksum, bad magic or bad geometry counted as "nothing to recover", so mount started a new journal over it and dropped any committed transactions. Now only an all-zero header, which format writes, counts as fresh. Anything else fails the mount:

Journal recovery for slot 0 failed: journal at offset …: failed to read journal superblock: journal superblock checksum mismatch (mount with -skip-recovery to discard this journal)

-skip-recovery still mounts and starts a new journal. The cmd/mount change is that one log line.

Behavior change for peers: ReplayJournal used to skip a slot with bad magic. It now returns an error, so the registry logs it and retries after the recovery lease instead of skipping the slot.

Tests (the new ones fail on main): journal unit tests, TestMountRefusesDamagedJournal, unit -race, integration -short (84 pass, 16 skip), 30 s of FuzzJournalSuperblock/FuzzJournalScan, and golangci-lint v2.

🤖 Generated with Claude Code

mattmattox and others added 2 commits October 24, 2026 17:06
ScanAndRecover treated any journal it could not open as "nothing to
recover", so mount started a new journal over a slot whose header had
a bad checksum, bad magic or bad geometry, and dropped any committed
transactions in it. Only an all-zero header, which format writes, now
means never initialized. Anything else fails the mount with the slot
number; -skip-recovery still mounts and starts a new journal.

ReplayJournal used invalid magic as its "no journal" signal; it now
uses the same all-zero check, so a peer reports a damaged slot instead
of skipping it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mount with -skip-recovery on the same host before it reboots. A slot
whose owner rebooted or never returns stays taken; nothing frees it
yet. Also fail the test helper on a bad offset instead of damaging
offset 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattmattox
mattmattox merged commit e31fa92 into main Oct 24, 2026
8 checks passed
mattmattox added a commit that referenced this pull request Oct 24, 2026
* docs: sync operator guides with current flags and behavior

OPERATIONS, DEPLOYMENT and TROUBLESHOOTING still used the old
goclusterfs binary name, a -format without -mount, a .snapshots
directory and snapshot API that never existed, lost+found, a
-fuse-debug flag, a mount -version flag, pprof, and read-only mounts.

They now match the code at e31fa92: format v2 and per-node journals,
-skip-recovery and damaged journal slots (#34), fsck exit codes and
-repair (#32), -attr-timeout (#24), lock renewal and takeover (#13,
#23), xattr snapshots and clones (#16), and the real log lines.

OPERATIONS.md gains a Security Model section: trust in the shared
device, single-user mounts with no permission checks, lock limits,
and unauthenticated broadcast unless -broadcast-secret is set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: lock waits have no time limit

ErrLockTimeout only fires when the request context is cancelled;
lock.DefaultTimeout is never used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: make damaged-journal recovery safe and fix review findings

-skip-recovery discards the journal of whichever slot the mount takes,
which is not the damaged slot once a peer holds its recovery lease.
The steps now say when to run it and how to check the slot, and only
use it for a damaged header, not for I/O or replay errors.

Also quote the real legacy-layout and superblock errors, cover a v2
device with a wiped superblock, state that there is no HTTP API, and
correct peer-announce, replay, unicast fallback and cache lag claims.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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