Repository navigation
Description
Summary
PR3.15, merged as pull request #89 (6daf90b), works around a defect in the libSQL client library. On a database file, a write batch that fails with SQLITE_BUSY at the busy timeout leaves its own BEGIN IMMEDIATE in progress. The native binding resets a statement only before it runs it again, and the client prepares a new statement for every call, so only the garbage collector finishes it. Until then every COMMIT on that connection fails with SQL statements in progress, reads and later writes alike.
Delete the workaround once a library release finishes that statement itself.
Where it stands
- The workaround is in
LibsqlExecutor(executor.ts). After a failed batch on a file, the next batch asks the connection with an empty read transaction and replaces one that refuses, checking that the new one reaches the same file. A file's batches run one at a time. - The lockfile on main pins
@libsql/client0.15.15 and the bindinglibsql0.5.29, under the range^0.15.0in package.json. DESIGN.md section 3.2 records the defect as still present in@libsql/client0.18.0. - Upstream: tursodatabase/libsql-client-ts#352 carries our comment, posted on 2026-09-21. Our fix, libsql-js#237, was closed in favour of libsql-js#238, which the library's maintainer wrote on top of our commit. It resets a statement after
run()succeeds or fails. BUILD.md on main records it as not yet released. - The case under
canary on the client libraryin failed-batch-recovery.test.ts requires the defect on the raw client. When a release fixes it, the case fails and points at the PR3.15 entry of BUILD.md.
What to do next
- Wait for libsql-js#238 to ship in a
libsqlrelease, and for an@libsql/clientrelease that depends on it. - Move
packages/store-libsqlto that client and refreshpnpm-lock.yaml. CI installs with--frozen-lockfile, and the range^0.15.0admits no 0.16 or later. - Run
pnpm exec vitest run packages/store-libsql/test/failed-batch-recovery.test.tsand see the canary fail by name. If it still passes, the release lacks the fix: stop, and revert the bump unless it is wanted for its own sake, because the reconnect reasoning in DESIGN.md section 3.2 is written for 0.15. - Delete what the "WHEN TO DELETE THE WORKAROUND" bullet of the PR3.15 entry in BUILD.md lists. That bullet is authoritative. In short:
- from
LibsqlExecutor: the question, the close and the reconnect, the recorded file and its two checks, and the one-at-a-time queue unless something else has come to rely on it; - the canary, the six cases of
failed-batch-recovery.test.tsthe bullet names, and the reconnect cases of reconnect-file-identity.test.ts, keeping its empty path andfile::memory:cases; - from scripts/mutation-probe.py:
libsql-suspect-connection-is-askedandlibsql-reconnect-refuses-another-file, andlibsql-file-batches-run-one-at-a-timeif the queue goes.
- from
- Remove the labels of deleted mutations from cases that stay in
failed-batch-recovery.test.ts: the question'smutation-verdict:behavior:label in the next-write case and, if the queue goes, the queue's in the queued-read case. The mutation probe refuses a label with no registered mutation. - Keep every other case green, including the upper-case
FILE:scheme, the next read, next write and queued read after a failed batch, and the two shared cases in executor-errors.ts on all three dialects. - Update DESIGN.md section 3.2 and the PR3.15 entry in BUILD.md, which both describe the workaround as shipped.
- Walk
/pr-gateand runpnpm verifybefore pushing.
Exit test
This issue owns no line of the current milestone (lines 32 to 44 of BUILD.md on operable-alpha-milestone). The deletion must keep line 27, the completed PR3.15 line, true without the workaround: after a write batch fails busy, "the same executor answers the next read while the lock is still held, the next write once it is free, and a read that was made in the same tick and was waiting behind the failed write". Its clause that a new connection reaches only the file it opened stops applying once the reconnect is gone, and the PR3.15 entry should say so.
Depends on
- libsql-js#238, or another fix that finishes a statement whose step failed busy, in a
libsqlrelease. - An
@libsql/clientrelease that takes it.
Nothing in this repository blocks it.
Open decisions
None blocks this issue. PR3.15 chose its fix without the maintainer and records two other shapes as options, for use if upstream stays unfixed:
- A lock probe while a lock outage lasts. Trigger: a deployment observed to accumulate descriptors during a lock outage.
- The executor framing a file's transaction itself, deleting the question, the reconnect and the canary at the price of a second write path. Trigger: upstream still unfixed when the first trigger is observed, or the recovery misbehaving in use.
Activity