8000 fix(db): usize::MAX threshold suppresses the close-time save too (#476) by adityamukho · Pull Request #526 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(db): usize::MAX threshold suppresses the close-time save too (#476) - #526

Merged
adityamukho merged 2 commits into
v3from
fix/476-sentinel-drop-save
Oct 10, 2026
Merged

adityamukho merged 2 commits into
v3from
fix/476-sentinel-drop-save

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Closes #476.

Decision

Took the first option in the issue: the sentinel now suppresses the save in PersistentFactStorage::drop as documented, rather than changing the docs. The SyncMode::Normal docs, the benchmark helpers, tests/error_codes_wal_test.rs and several WAL tests all rely on usize::MAX meaning "nothing written to the file on close". Nothing is lost: the WAL holds every pending fact and the next open replays it.

Changes

  • Inner::drop: under wal_checkpoint_threshold == usize::MAX, discard the storage's dirty flag (file-backed, read-write only), so its drop saves nothing.
  • OpenOptions::wal_checkpoint_threshold field docs: say what usize::MAX does.
  • Regression test test_max_threshold_drop_leaves_graph_file_untouched (tests/wal_test.rs): under Full and Normal, two transacts then drop leave the .graph file byte for byte unchanged and keep the WAL; a reopen replays the entries.
  • CHANGELOG (Unreleased → Fixed), test counts (1425 / 1415 passing) in CLAUDE.md, README.md, docs/TEST_COVERAGE.md.

Not changed: the v8 golden generator's stale_wal recipe relied on the old drop-save, but the generator is pinned to rev 23aa57c and never re-run, so the committed fixture and recipe stay as they are. The #385 model test's Crash step still copies files while the handle is open; it works as is. The docs site's tuning page already tells bulk loaders to call checkpoint() explicitly, so nothing there contradicts this. Not backported to v2.x: no data-integrity impact.

Verification

  • cargo test: 1415 passed, 0 failed, 10 ignored.
  • cargo clippy --all-features -- -D warnings, plus wasm32-unknown-unknown --features browser and wasm32-wasip1: clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h

adityamukho and others added 2 commits October 10, 2026 23:11
`wal_checkpoint_threshold(usize::MAX)` was documented to suppress the
close-time checkpoint, and `Inner::drop` skipped it, but
`PersistentFactStorage::drop` still saved whenever it was dirty. Closing
the handle wrote every pending fact to the .graph file and left a WAL
whose entries were all checkpointed.

`Inner::drop` now discards the storage's dirty flag under the sentinel.
The WAL holds every pending fact and the next open replays it. The
v8 golden generator is pinned to 23aa57c and never re-run, so its
`stale_wal` recipe, which relied on the old save, is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h
Use get_mut() in Inner::drop (no lock needed with &mut self), dropping
the untakeable poisoned-lock arm, and add a unit test for an in-memory
handle under usize::MAX. src/db.rs branch coverage fell below its 87%
floor without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012wXxZguv7PgKQjMMH4yJ5h
@codecov
codecov Bot commented Oct 10, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit bc7a6b6 into v3 Oct 10, 2026
24 checks passed
@adityamukho
adityamukho deleted the fix/476-sentinel-drop-save branch October 10, 2026 18:05
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