Repository navigation
Give SQLite writes one pooled connection, and change the version only when the owner asks - #599
Merged
James-Chapman merged 3 commits intoNov 18, 2026
Conversation
…Lite's busy handler for another (1.1.4) The DB-7 scenario lost three of 64 writes under load: three pooled SQLite connections being opened polled SQLite's busy handler for the first one's lock, lost to its back-to-back commits (every journal and database sync runs under EXCLUSIVE) and were refused after 5 s with SQLITE_BUSY. SQLite runs one write at a time, so the SQLite write pool now holds one connection whatever database.pool_size says, and writers wait in the pool instead (ADR-0834). database.pool_size applies to PostgreSQL only. A new scenario holds SQLite's write lock on a leased pool slot for 7 s while a second write runs; on the old code that write was refused at BEGIN IMMEDIATE after the busy timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nvariants Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
…1.1.3 The owner's rule from 2026-11-18: no branch increments the version on its own; it changes only when the owner asks, and every change adds its CHANGELOG bullets to the newest version's entry (ADR-0835, superseding ADR-0464 and the per-branch increment of ADR-0647). docs/versioning.md, the root AGENTS.md, docs/coding-rules.md, docs/AGENTS.md and the review skill now say so. Under the new rule this branch drops its 1.1.4 bump: every version location is back to its base's 1.1.3, and the SQLite fix's bullet and release-notes sentence move into the 1.1.3 entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
James-Chapman
merged commit Nov 18, 2026
a20f5da
into
claude/livekit-token-service-bde17e
3 of 7 checks passed
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
Stacked on #598 (merge order: #594 → #595 → #597 → #598 → this). Under sustained write load a SQLite server could refuse writes with
SQLITE_BUSY: the write pool opened up todatabase.pool_sizeSQLite connections, and every connection after the first waited for the first one's lock in SQLite's polling busy handler, lost to its back-to-back commits and gave up after 5 s. SQLite runs one write at a time, so its write pool now holds exactly one connection and writers wait in the pool instead (ADR-0834).At the owner's request this branch also changes the versioning rule: the version now changes only when the owner asks, so this branch stays at #598's 1.1.3 and adds its CHANGELOG bullets to that entry (ADR-0835).
What changed
SqliteWritePoolholds aConnectionPoolof limit 1;set_write_connection_limit(database.pool_size) now changes only the PostgreSQL pool, and the SQLite overload ofdetail::set_write_pool_limitis gone.docs/database-persistence.md, thedatabase.pool_sizerow ofdocs/user-manual.md,src/database/AGENTS.mdrule 7 and the review skill's database invariants say SQLite has one write connection.docs/adr/index.md.docs/versioning.md(scheme, history, bump policy, release process), the rootAGENTS.md,docs/coding-rules.md,docs/AGENTS.mdand the review skill (SKILL.md,references/obligations.md) state the new rule.Why it changed
The DB-7 scenario lost 3 of 64 writes in a full run on a loaded VM (2026-11-17, during #598's work): three
connection.rejected sqlite_code=5/transaction.failed stage=openlines, all within 14 ms of each other and 5.3 s after the store opened. So they waited out the whole busy timeout together; nothing skipped the busy handler.In rollback-journal mode a committing connection holds PENDING or EXCLUSIVE for the whole commit, including both journal syncs and the database sync (
syncJournaltakes EXCLUSIVE before its first sync), and PENDING refuses every new SHARED lock. One pooled connection committing back to back holds the lock almost all the time and takes it again within microseconds of releasing it. Another connection of the same process, polling every 100 ms by then, rarely lands in the gap. The opening connections needed SHARED to read the schema while pinning their pragmas, and were refused. A write behind one slow write for more than 5 s is refused the same way.The busy timeout still governs this process's reads against its writer, and locks other processes take; reads are unchanged here.
The versioning rule changed because the owner asked that the version move only on request, not once per branch.
CI tests
Modified:
tests/integration/test_security_audit_write_pool_flow.cpp: "DB-7 concurrent writes to SQLite share one connection, whatever database.pool_size allows" (renamed from "... reuse at most database.pool_size connections"); 64 concurrent writers all commit andwrite_connections_opened == 1.New:
tests/integration/test_security_audit_write_pool_flow.cpp: "A SQLite write waits for another write of this process for longer than SQLite's busy timeout" ([db7]). It holds SQLite's write lock on a leased slot of the store's own pool for 7 s while a second write runs. Run against the unfixed code on the VM, it failed as intended:transaction.failed stage=begin sqlite_code=5,second_committedfalse, 1 room stored instead of 2.Verification:
python build.py vmon the fix before it was stacked on #598 (based onmain, with the SQLite change and both scenarios): Ok 85, Fail 0, no timeouts;integration-teststook 989 s. The stacked head (9b645b3a, with the versioning docs) was not run locally at the owner's request; CI covers it.🤖 Generated with Claude Code