Repository navigation
fix(db): checkpoint removes a WAL whose entries are all checkpointed (#457) - #525
Merged
Merged
Conversation
…457) do_checkpoint returned early when it had nothing to flush, which also skipped deleting the WAL. A WAL left by a crash between a checkpoint's commit and its WAL delete, or by a failed delete, therefore stayed until a later write was checkpointed. Every entry in it is at or below the committed tx count, so the early return now deletes it (with the parent directory sync) instead. The golden-corpus test no longer exempts the stale_wal fixtures from the WAL-gone check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #457.
Problem
do_checkpointreturned early whenwal_entry_count == 0 && !pfs.is_dirty(), and that early return also skipped deleting the WAL. Replay counts only the entries it applies, so a WAL whose entries were all checkpointed already gave a count of 0. The WAL then stayed until a later write was checkpointed. This happens after a crash between a checkpoint's commit and its WAL delete, or after a failed delete (WAL-006). No data was affected, because replay skips those entries.Fix
On the early-return path, call
delete_wal. It removes the file if it exists and syncs the parent directory, as the normal path does. Every entry is at or below the committedlast_checkpointed_tx_count, so deleting the file loses nothing.Tests
tests/wal_test.rs:test_checkpoint_removes_wal_whose_entries_are_all_checkpointedrestores a stale WAL after a checkpoint, reopens and checkpoints, then checks:It fails without the fix.
tests/golden_corpus_test.rs: dropped thestale_walexemption, sov7_stale_walandv8_stale_walmust also have no WAL after a checkpoint. The manifests keep the flag as a description of the shape (tests/golden/README.mdupdated).Docs: CHANGELOG (Fixed), test counts in CLAUDE.md, README and TEST_COVERAGE (1424 / 1414 passing). No v2.x backport, because this is not a data-integrity fix.
🤖 Generated with Claude Code
https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h