Skip to content

Refuse data log reads and appends after a swap that can't recover - #180

Merged
saworbit merged 1 commit into
mainfrom
fix/data-log-lost-after-swap
Nov 13, 2026
Merged

saworbit merged 1 commit into
mainfrom
fix/data-log-lost-after-swap

Conversation

@saworbit

Copy link
Copy Markdown
Owner

When compaction's rename fails and reopening the old log fails too, the data log kept a handle to the file it had just removed. Appends went there and were lost at the next restart. Reads looked up old offsets in the wrong file.

Now that branch marks the log lost, as the journal already does. Reads, appends, record checks and compaction are refused with an error that says to open the store again. serve-s3's reclaim pass already logs the error.

Tests inject the rename and reopen failures through test-only flags. One checks a failed rename alone leaves the log usable. The other checks nothing is appended or read after both fail, and that reopening recovers.

Local: cargo test -p nvram-sim --lib (19 passed), fmt and clippy clean. The new test fails with the fix disabled.

Fixes #150

When compaction's rename fails and the old log can't be reopened, the log is marked lost, as the journal already does. Appends no longer go to the removed file, and reads no longer use the old generation's offsets.

Fixes #150
@saworbit
saworbit enabled auto-merge (squash) November 13, 2026 09:11
@saworbit
saworbit merged commit feb373b into main Nov 13, 2026
3 checks passed
@saworbit
saworbit deleted the fix/data-log-lost-after-swap branch November 14, 2026 21:54
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.

[Core] Refuse data log appends after a compaction swap that can't recover

1 participant