Repository navigation
fix(session): reserve the WAL writer before reading revisions - #1452
Merged
Merged
Conversation
This was referenced Nov 28, 2026
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.
Closes #1451.
Workflow Session persistence reads the stored revision before upserting a Session. With a deferred transaction, another connection can commit to the shared WAL between those statements. SQLite then rejects the Session write because its read snapshot is stale.
Start each dirty Session batch with
BEGIN IMMEDIATE. The writer now acquires its reservation under the existing five-second busy timeout before checking revisions. The batch still commits atomically after the revision and identity checks.The regression exercises the SessionStore flush path against a temporary file. A SQLite statement hook in the test attempts an insert into an unrelated audit table just as the Session upsert is prepared. This puts the competing write after the revision read without relying on sleeps.
Validation
Session persistence failed: database is locked. With this fix, the test verifies that the competing insert sees a busy writer, both Session events reach disk, and the audit insert succeeds after the flush.cargo test --locked -p webcodex-workflow-session --libon macOS passed with 303 tests and 8 ignored. The passing tests include batch rollback and stale writer coverage.cargo fmt --all -- --checkandgit diff --checkpassed.