Repository navigation
refactor(sqlite): one shared operator write-lock poll for store and auth - #1074
Merged
Merged
Conversation
#1071 (auth) and #1073 (store) each carried a copy of the same operator connection logic: retry BEGIN IMMEDIATE every millisecond with busy_timeout 0 up to a 10 s deadline, then restore the timeout, plus a SQLITE_BUSY check. Move it into core's @jimhoyd/urlcode/sqlite subpath as beginImmediateWithin(db, waitMs, begin) and call it from both packages. The error surfaced is still SQLite's own, rethrown unchanged. The identical slow-commit writer fixtures become one test/slow-commit-writer.ts. Part of #1041 Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
enabled auto-merge (squash)
September 30, 2026 18:09
jimhoyd
added a commit
that referenced
this pull request
Sep 30, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 30, 2026
jimhoyd
added a commit
that referenced
this pull request
Sep 30, 2026
…ter recent merges (#1076) - FRAMEWORK.md, STORE.md: urlcode benchmark was removed (#1048); test runs are urlcode test and audit. - STORE.md: quote the server-lock refusal as core now words it (#1069). - TYPESCRIPT.md: list beginImmediateWithin on @jimhoyd/urlcode/sqlite (#1074). - store CHANGELOG (unreleased): several servers need a database server the bundled store does not use, not one URLCode does not provide (#1052). - llms-full.txt regenerated. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Part of #1041
What
#1071 (
packages/auth,openAuthDatabase(path, {operator})) and #1073 (packages/store/src/database.ts,openStoreDatabase(path, {operator: true})) each added their own copy of the same logic: an operator connection that retriesBEGIN IMMEDIATEevery ~1 ms withbusy_timeout=0up to a 10 s deadline, then restores the timeout, plus a SQLITE_BUSY (extended codes included) check.This moves it into one helper in core's
@jimhoyd/urlcode/sqlitesubpath (defined inpackages/core/src/server-lock.ts, re-exported bypackages/core/src/sqlite.ts):beginImmediatenow calls it with() => db.exec('BEGIN IMMEDIATE').beginstatement proxy'sruncalls it with() => target.run()(Better Auth's dialect still gets the statement's ownrun()result).busycheck, which matches the primary code only, is left as it is.OPERATOR_LOCK_WAIT_MS.slow-commit-writer.tsfixtures become onetest/slow-commit-writer.ts. The only change in the two tests is the path they spawn.docs/EXTENSIONS.mdSQLite helpers table. TheRIM-STORE-PERSIST-001card listsbeginImmediateWithin, describes the operator poll and cites the operator-lock tests.llms-full.txtis regenerated.Measure (
git diff --numstat origin/main)Net -43 lines (code and tests alone: +45 / -90).
Evidence
packages/store/test/operator-lock.test.tsandpackages/auth/test/auth.test.ts(the create-user-beside-a-slow-committing-server test) pass. Apart from the fixture path, neither test changed.npm run verifyis green locally (macOS). The first run failed only on the stalellms-full.txtcheck, whichnpm run docs:llmsregenerated.🤖 Generated with Claude Code