design(daemon): WAL checkpointing at shutdown across platforms - #934
Draft
kriscendobot wants to merge 1 commit into
Draft
design(daemon): WAL checkpointing at shutdown across platforms#934kriscendobot wants to merge 1 commit into
kriscendobot wants to merge 1 commit into
Conversation
Answers the pet-store SQLite parity design's open question (WAL checkpointing on shutdown?) flagged in PR #124 review. Replaces the incidental last-connection auto-checkpoint with an explicit wal_checkpoint(TRUNCATE) folded into the shared close(), uniform across Node (better-sqlite3) and Rust+XS (rusqlite), so a graceful shutdown leaves a self-contained endo.sqlite. Makes file-level snapshot and cross-supervisor handoff single-file-safe and pins the crash-path recovery-on-open contract. No new Rust host function. Registered in designs/README.md (summary table + M11 milestone).
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.
Summary
Design doc: SQLite WAL Checkpointing at Shutdown, Cross-Platform (
designs/daemon-sqlite-shutdown-checkpoint.md).Answers the open question left in the pet-store SQLite parity design (
designs/daemon-endor-pet-store-sqlite.md, PR #124), "WAL checkpointing on shutdown?", whose draft answer concluded thatjournal_mode = WALplus a cleandb.close()was sufficient. Per the maintainer's review comment on that line (#124 (comment)) asking to design checkpointing at shutdown across all supported platforms.Why the draft answer was incomplete
"Clean
db.close()is sufficient" is true only incidentally: SQLite auto-checkpoints the WAL only when the last connection closes cleanly, inPASSIVEmode, and it is skipped on abrupt termination, on a stray second connection, or underSQLITE_FCNTL_PERSIST_WAL. That leaves three gaps once the daemon runs on more than one platform and its state is snapshotted or handed off:endo.sqlitewhile a WAL exists misses every un-checkpointed write.What the design proposes
checkpoint(mode = 'TRUNCATE')method on theDatabasecontract, folded into the sharedclose()inmakeDaemonDatabasebefore the backend close, uniform across Node (better-sqlite3) and Rust+XS (rusqlite).TRUNCATEleaves a zero-length-wal, so a graceful shutdown produces a self-containedendo.sqlite: single-file snapshot and sidecar-free reopen become correct by construction.wal_checkpointis a pragma and rides the existinghost_sqlite_execseam. The Rust side re-prepares statements per call, so there is no zombie-close risk atsqlite3_close.sqlite-parity.test.js) with four cases: self-contained-file-after-close, single-file cross-platform handoff, same-platform crash recovery, cross-platform crash recovery.Registered in
designs/README.md(summary table + M11 milestone table).Draft: design-stage, for review before un-drafting. Mermaid diagram parse-validated. Open questions (suspend/resume checkpoint call, concrete
journal_size_limit, defense-in-depth checkpoint inhost_sqlite_close) are enumerated in the doc.