8000 fix(db): stale WAL removed by checkpoint; usize::MAX threshold skips close-time save (#457, #476, v2.x backport) by adityamukho · Pull Request #540 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(db): stale WAL removed by checkpoint; usize::MAX threshold skips close-time save (#457, #476, v2.x backport) - #540

Merged
adityamukho merged 1 commit into
mainfrom
fix/457-476-v2-backport
Oct 11, 2026
Merged

adityamukho merged 1 commit into
mainfrom
fix/457-476-v2-backport

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

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 checkpointed

do_checkpoint returned 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_file syncs the parent directory). Every entry is at or below the committed tx count, so nothing is lost.

v2.x has no delete_wal helper, so the early return drops the writer and calls WalWriter::delete_file itself.

#476: close-time save ignored wal_checkpoint_threshold(usize::MAX)

Inner::drop skipped its checkpoint under the sentinel, but PersistentFactStorage::drop still saved dirty facts. Inner::drop now clears the storage's dirty flag first (new PersistentFactStorage::discard, non-wasm), so close writes nothing to the .graph file and the WAL keeps the pending facts for the next open. The OpenOptions::wal_checkpoint_threshold field docs say what usize::MAX does. v2.x has no read-only open, so the v3 read_only branch is left out.

Tests

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

…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
@adityamukho
adityamukho merged commit 99410b1 into main Oct 11, 2026
21 checks passed
@adityamukho
adityamukho deleted the fix/457-476-v2-backport branch October 11, 2026 08:06
@codecov
codecov Bot commented Oct 11, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

0