Repository navigation
fix(rusqlite-runtime): admit stores left by an interrupted checkpoint - #4913
Open
ScriptedAlchemy wants to merge 1 commit into
Open
ScriptedAlchemy wants to merge 1 commit into
ScriptedAlchemy wants to merge 1 commit into
Conversation
ScriptedAlchemy
enabled auto-merge
November 17, 2026 02:30
|
A daemon killed while closing its stores can leave a main file mixing committed generations beside a WAL that no live connection maps. SQLite recovers that state from the WAL, but pin_initialized refused it: the immutable main-only view fails every statement, and a disconnected WAL recovers into a heap index that cannot prove SHM ownership. The daemon then crash-looped on "existing SQLite file has no valid database header". FinishInitialSchema stamps the registered application ID and must then checkpoint it into the main file, so that header proves the store was published and owns its sidecars. Read it through the inspection connection's VFS file and admit the store when its nonempty WAL completes the schema view. Unstamped files and stores with no recoverable WAL are still refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ScriptedAlchemy
force-pushed
the
fix/session-store-open-unckpt-wal
branch
from
November 17, 2026 02:33
231e86a to
49ce939
Compare
This branch has not been deployed
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.
Problem
After
tracedecay update(beta.105 → beta.106) the daemon crash-looped (86 restarts) with:The old daemon was killed during
store_closewhile checkpointing~/.tracedecay/user-sessions.db(7 GB, 55 MB WAL). That left the standard SQLite crash state: a main file mixing committed generations plus a WAL holding every committed frame.PRAGMA quick_checkwith the WAL wasok; the data was intact.OpenedDatabaseFile::pin_initializedrefused it:live_wal_has_store_schema) read the full schema through the WAL, but its shared-index check returnedSQLITE_READONLY_CANTINIT(rc 1288): no live process maps the WAL index, so SQLite recovered it into a heap index, which the guard deliberately rejects. An empty-journalleft by initialization also disqualified the fallback.Fix
FinishInitialSchemastampsapplication_id = TDSTand must thenwal_checkpoint(TRUNCATE)it into the main file, so aTDSTmain header proves the store was published and owns its sidecars.pin_initializednow reads that header through the inspection connection's own VFS file (no new descriptor, so no POSIX-lock hazard). It admits the store when that header is present and a nonempty WAL completes the schema view. SQLite's ordinary recovery then restores the frames on the next writable open.Unchanged refusals:
InvalidHeader/IncompleteInitialization.live_wal_recovers_an_inconsistent_immutable_checkpoint_view).Verification
crash_interrupted_checkpoint_of_a_published_store_remains_attachable: failed withInvalidHeaderbefore the fix. It now admits the stamped store, refuses the identical unstamped files, and SQLite recovery returns the committed row withquick_check = ok.cargo test -p tracedecay-rusqlite-runtime --lib: 483 passed.cargo clippy -p tracedecay-rusqlite-runtime --all-targets -D warningsand//crates/tracedecay-rusqlite-runtime:rustfmt_check_2024pass.pin_initializedwent fromErr(InvalidHeader)toOk, leaving the sidecars untouched.🤖 Generated with Claude Code