Repository navigation
fix(db): stale WAL removed by checkpoint; usize::MAX threshold skips close-time save (#457, #476, v2.x backport) - #540
Merged
Conversation
…lose-time save (#457, #476) Backport of #525 and #526 (v3) to v2.x. - #457: do_checkpoint's early return (nothing to flush) now deletes a WAL whose entries are all already in the file, and syncs the parent directory. The golden-corpus test requires v7_stale_wal to have no WAL after a checkpoint. - #476: Inner::drop under wal_checkpoint_threshold(usize::MAX) discards the storage's dirty flag, so PersistentFactStorage::drop saves nothing; the WAL keeps the pending facts for the next open. OpenOptions field docs say what usize::MAX does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h
This was referenced Oct 11, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Oct 13, 2026
Merged
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.
Backport of #525 (#457) and #526 (#476) from v3 to v2.x.
Neither is a data-integrity fix. They are backported because PHILOSOPHY.md §7 gives the latest 2.0.x minor all bug fixes until v3.0.0 ships (same basis as #538).
#457:
checkpoint()left a WAL whose entries were all checkpointeddo_checkpointreturned early when it had nothing to flush, and that early return also skipped deleting the WAL. Such a WAL is left by a crash between a checkpoint's commit and its WAL delete, or by a failed delete (WAL-006). Now the early return deletes the WAL if it exists (WalWriter::delete_filesyncs the parent directory). Every entry is at or below the committed tx count, so nothing is lost.v2.x has no
delete_walhelper, so the early return drops the writer and callsWalWriter::delete_fileitself.#476: close-time save ignored
wal_checkpoint_threshold(usize::MAX)Inner::dropskipped its checkpoint under the sentinel, butPersistentFactStorage::dropstill saved dirty facts.Inner::dropnow clears the storage's dirty flag first (newPersistentFactStorage::discard, non-wasm), so close writes nothing to the.graphfile and the WAL keeps the pending facts for the next open. TheOpenOptions::wal_checkpoint_thresholdfield docs say whatusize::MAXdoes. v2.x has no read-only open, so the v3read_onlybranch is left out.Tests
tests/wal_test.rs:test_checkpoint_removes_wal_whose_entries_are_all_checkpointed(WAL whose entries are all checkpointed survives checkpoint() until the next write #457) andtest_max_threshold_drop_leaves_graph_file_untouched(Close-time save ignores wal_checkpoint_threshold(usize::MAX) #476). Both fail without their fix.tests/golden_corpus_test.rs: the WAL-gone check after a checkpoint now applies on v2.x too (it was gated onREADER >= 3), sov7_stale_walmust lose its WAL. Fails without the WAL whose entries are all checkpointed survives checkpoint() until the next write #457 fix.src/db.rsunit testtest_max_threshold_in_memory_drop.cargo test: 1232 passed, 0 failed, 9 ignored.cargo clippy --all-features -- -D warningsclean; wasm32 builds compile with no new warnings.Docs: CHANGELOG (Unreleased → Fixed), test counts in CLAUDE.md, README.md, docs/TEST_COVERAGE.md (1,241 tests).
Refs #457, #476.
🤖 Generated with Claude Code
https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h