Repository navigation
fix(shared): checkpoint WAL without blocking foreground writes - #1000
Merged
Merged
Conversation
Canceled elected wakes could strand a later reserved SQL statement after WAL admission reopened. Keep one waiter elected through its retry's final synchronous gate check, hand cancellation to the next eligible waiter, and make only transaction and reserve permit acquisition interruptible. Focused cancellation, ownership, fairness, BEGIN, and admission tests pass (11 tests). The full adapter has 47 passing tests and one blob failure matching the pinned-base result (expected 65537, got null). Scoped format, lint, and shared typecheck pass. Implemented with GPT-6 Luna max in the T3 Code Codex harness.
JustYannicc
temporarily deployed
to
cloud-preview
October 17, 2026 23:19 — with
GitHub Actions
Inactive
This was referenced Oct 17, 2026
This branch was previously 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
A foreground SQLite write can checkpoint the WAL while the server handles a request. The #779 reproduction held about 16,000 pending frames and stalled a small delete for 5.48 seconds.
Change
Run checkpoints on a worker and pause new writes when it falls behind. The writer acknowledges a pause before the worker takes the exclusive truncation lock. Final admission and synchronous SQL execution share one callback, and worker generations prevent stale replies from reopening the gate.
Each statement holds its selected connection permit through execution. Transactions retain that permit through completion. Waiting statements, transactions and reserved connections honor the caller's cancellation mask. Ordinary waits can cancel, while masked cleanup and claimed webhook delivery finish. Cancellation hands an elected wake to the next writer and cannot leave a claimed permit without cleanup. Reads and active transaction completion stay available.
Mutating pragmas and partially committed statement failures update checkpoint accounting. Unsupported SQLite versions or worker failure retain the existing writer-checkpoint fallback.
The 10,000-frame threshold bounds admission between statements and transactions. A single statement or transaction can cross it, and an external reader can hold the write gate closed until its snapshot ends. This affects the shared Node SQLite adapter used by the app server. Cloud Durable Objects use a separate store.
Scope and approval
Addresses item 2 of #779. The other slowdown fixes and database-growth retention work have separate PRs.
Verification
keeps large text and blob parameters off cached statements. The precise local cause has not been isolated.Independent review: GPT 6.1 Sol xhigh (Opus unavailable: rate-limited at 2026-10-17 15:47:05 UTC). Candidate
34bf59676ffcddd3b717071635383872a3fd6498passed independent standards and input reviews with no findings, including the caller-mask correction after the first CI run.Implemented with GPT 6.0 Luna max; integrated and reviewed with GPT 6.1 Sol through the Codex harness in T3 Code.