Skip to content

file: — SQLITE_BUSY-failed statement is never finalized; next transaction cannot commit and its abandoned BEGIN holds the write lock forever #352

Open

Description

@josiahruddell

On a local file: database, a statement that fails with SQLITE_BUSY is never finalized on the client's shared native connection. The next transaction() on that client then fails at commit() with:

SQLITE_BUSY: cannot commit transaction - SQL statements in progress

and — because transaction() hands the current native connection to the transaction and nothing ever closes it (#350) — if the caller does not explicitly roll back, the open BEGIN holds the database write lock until the process exits. Every subsequent write from any connection fails SQLITE_BUSY immediately.

This is the mechanism behind two production outages for us (the caller was @prisma/adapter-libsql, which never issues a successful rollback after a failed commit — filed as prisma/orm#30028 — but the underlying behavior is reproducible with @libsql/client alone).

Two findings from the repro below:

  1. The priming step is just one transient SQLITE_BUSY (in production: a Litestream checkpoint briefly holding the write lock). The client looks healthy afterwards; the corruption only surfaces at the next transaction's commit. Likely the same statement-finalization gap as Database.close() does not finalize prepared statements — WAL file lock held until GC libsql-js#228.
  2. An explicit rollback() after the failed commit does succeed and releases the lock — so the state is recoverable, but only if the caller knows to do this. Callers that treat a failed commit as "transaction closed" (a reasonable assumption, and what Prisma's engine does) leak the lock permanently.
repro.mjs — @libsql/client 0.17.4, Node 24, needs `sqlite3` CLI on PATH
import { execFile } from 'node:child_process'
import { createClient } from '@libsql/client'

const client = createClient({ url: 'file:./repro2.db' })
await client.execute('CREATE TABLE IF NOT EXISTS t (id INTEGER PRIMARY KEY, v TEXT)')
await client.execute('PRAGMA journal_mode = WAL')
await client.execute("INSERT OR REPLACE INTO t (id, v) VALUES (1, 'base')")

const write = async (label) => {
  try {
    await client.execute({ sql: 'UPDATE t SET v = ? WHERE id = 1', args: [label] })
    console.log(`${label}: OK`)
  } catch (e) {
    console.log(`${label}: FAIL ${String(e.message).slice(0, 80)}`)
  }
}

// 1. Prime: a write fails SQLITE_BUSY while another process holds the lock.
const holder = new Promise((res) =>
  execFile('bash', ['-c', `(echo "BEGIN IMMEDIATE; UPDATE t SET v='held' WHERE id=1;"; sleep 2; echo "COMMIT;") | sqlite3 repro2.db`], () => res()),
)
await new Promise((r) => setTimeout(r, 400))
await write('during-lock')     // FAIL SQLITE_BUSY — the priming statement
await holder
await write('after-release')   // OK — client looks healthy

// 2. Transaction with concurrent writes on the same client.
const tx = await client.transaction('deferred')
try {
  await tx.execute("UPDATE t SET v = 'itx' WHERE id = 1")
  await Promise.all([write('concurrent-1'), write('concurrent-2')])
  await tx.commit()
  console.log('tx: committed')
} catch (e) {
  console.log(`tx commit: FAIL ${String(e.message).slice(0, 90)}`)
  // NOTE: uncommenting this recovers — but a caller that assumes a failed
  // commit closed the transaction (e.g. Prisma) leaks the write lock forever:
  // await tx.rollback()
}

// 3. Recovery probes — all fail until the process exits.
for (let i = 1; i <= 4; i++) {
  await new Promise((r) => setTimeout(r, 700))
  await write(`recovery-${i}`)
}
process.exit(0)

Output (abandoned-tx variant):

during-lock: FAIL SQLITE_BUSY: database is locked
after-release: OK
concurrent-1: FAIL SQLITE_BUSY: database is locked
concurrent-2: FAIL SQLITE_BUSY: database is locked
tx commit: FAIL SQLITE_BUSY: cannot commit transaction - SQL statements in progress
recovery-1: FAIL SQLITE_BUSY: database is locked
recovery-2: FAIL SQLITE_BUSY: database is locked
recovery-3: FAIL SQLITE_BUSY: database is locked
recovery-4: FAIL SQLITE_BUSY: database is locked

Suggested fixes, any of which would break the chain: finalize failed statements before returning the error; make commit() roll back + close the detached connection when it fails with SQL statements in progress; or close the detached connection when the Transaction object is GC'd (#350 / libsql-js#230 territory).

Activity

  1. zsilbi commented on Sep 8, 2026

    @zsilbi

    Confirming this on @libsql/client 0.18.0, native libsql 0.5.29, Node 24.15.0, Linux x86_64.

    This reproduces with two clients in one process. No external SQLite CLI or sleeps are needed.

    An additional detail for 0.18.0: calling rollback() and close() after the failed commit does not restore recovery in this reproduction.

    Reproduction

    npm install --save-exact @libsql/client@0.18.0 libsql@0.5.29
    node repro.mjs
    import { createClient } from '@libsql/client';
    import { mkdtempSync, rmSync } from 'node:fs';
    import { tmpdir } from 'node:os';
    import { join } from 'node:path';
    
    const directory = mkdtempSync(join(tmpdir(), 'libsql-busy-'));
    const url = `file:${join(directory, 'test.db')}`;
    const first = createClient({ url, timeout: 0 });
    const second = createClient({ url, timeout: 0 });
    
    try {
      await first.execute('CREATE TABLE entries (id INTEGER PRIMARY KEY)');
    
      const held = await first.transaction('write');
      try {
        const unexpected = await second.transaction('write');
        unexpected.close();
        throw new Error('Expected SQLITE_BUSY');
      } catch (error) {
        if (error.code !== 'SQLITE_BUSY') throw error;
        console.log('Initial BEGIN:', error.message);
      } finally {
        await held.commit();
      }
    
      for (let attempt = 1; attempt <= 3; attempt++) {
        const transaction = await second.transaction('write');
        try {
          await transaction.execute('INSERT INTO entries VALUES (1)');
          await transaction.commit();
          console.log(`Retry ${attempt}: committed`);
        } catch (error) {
          console.log(`Retry ${attempt}:`, error.message);
          await transaction.rollback();
        } finally {
          transaction.close();
        }
      }
    
      try {
        await first.execute('INSERT INTO entries VALUES (2)');
        console.log('Other client: wrote successfully');
      } catch (error) {
        console.log('Other client:', error.message);
      }
    } finally {
      first.close();
      second.close();
      rmSync(directory, { recursive: true, force: true });
    }

    Observed output:

    Initial BEGIN: SQLITE_BUSY: database is locked
    Retry 1: SQLITE_BUSY: cannot commit transaction - SQL statements in progress
    Retry 2: SQLITE_BUSY: cannot commit transaction - SQL statements in progress
    Retry 3: SQLITE_BUSY: cannot commit transaction - SQL statements in progress
    Other client: SQLITE_BUSY: database is locked
    

    Expected: after the first client commits, the second client’s next transaction can insert and commit successfully.

    Additional findings

    • In 0.18.0, a failed transaction() returns its connection to the pool, allowing later attempts to reuse it.
    • commit() releases its transaction handle in finally, including on failure. A subsequent rollback() sees a null handle and returns. Pool release already attempts SQL rollback when db.inTransaction, but the reproduction still fails despite that cleanup.
    • With native libsql 0.5.29 alone, a failed db.prepare("BEGIN IMMEDIATE").run() causes a later commit on that connection to fail. Replacing only that failed operation with db.exec("BEGIN IMMEDIATE") allows the later transaction to commit. This points to cleanup of failed prepared statements.
    • Using db.exec for internal BEGIN statements fixed the failed-BEGIN case experimentally. However, failed ordinary writes can cause the same later commit failure, so this is only a partial workaround.

    Automatically reconnecting the client is unsuitable as a general recovery strategy: it closes other active transactions and loses private in-memory state.

  2. ejc3 commented on Sep 21, 2026

    @ejc3

    This adds to the report above: a reproduction against the libsql binding alone, the lines that cause it, a control that shows a reset is what is missing, and the smallest fix. Related: tursodatabase/libsql-js#228.

    Versions

    libsql 0.5.29 (tag v0.5.29, commit 55bee86), built on the Rust crates libsql, libsql-sys
    and libsql-ffi 0.9.30 (bundled SQLite 3.45.1). @libsql/client 0.15.15. Node 22, Linux x64.
    On @libsql/client 0.18.0 (published 2026-09-02) repro-client.mjs fails the same way,
    although that client's local connections are now a pool. Read, not
    run: the binding's main branch (0.6.0-pre.42) still resets a statement before it runs and not
    after its step fails.

    What happens

    1. Connection A holds the write lock of a WAL database file.
    2. Connection B runs BEGIN IMMEDIATE. After B's busy timeout the step fails with
      SQLITE_BUSY: database is locked. That is correct.
    3. A releases the lock.
    4. Every explicit transaction on B now fails at its COMMIT with
      SQLITE_BUSY: cannot commit transaction - SQL statements in progress, a read
      transaction and a write transaction alike, although B holds nothing and the lock is free.
    5. A third connection is not affected. B recovers only when the JavaScript garbage collector
      has finalized the failed statement object, which needs a collection and then a turn of the
      event loop. A process cannot force that.

    Through @libsql/client the same thing happens to client.batch(): one write batch that
    fails busy makes the following batches on that client fail, read and write. A lone
    execute() is not refused, because it sends no COMMIT of its own.

    Reproductions

    Each is one file with no other dependency. package.json pins the two packages. The files are below the list.

    • repro-binding.mjs: the binding alone. With node --expose-gc it also shows that a
      collection followed by a turn of the event loop ends the condition, and that a collection
      with no turn of the event loop does not.
    • repro-client.mjs: the same through @libsql/client.
    • repro-reset-control.mjs: the control. The statement object that failed, run a second
      time, works and leaves the connection whole with no garbage collection, because the binding
      resets a statement before it runs it.
    package.json
    {
      "name": "libsql-busy-statement-repro",
      "private": true,
      "type": "module",
      "dependencies": {
        "@libsql/client": "0.15.15",
        "libsql": "0.5.29"
      }
    }
    repro-binding.mjs
    // A statement whose step fails with SQLITE_BUSY stays "in progress" on its connection until
    // the JavaScript garbage collector finalizes it, and every COMMIT on that connection is
    // refused until then. Run: node repro-binding.mjs   and   node --expose-gc repro-binding.mjs
    import { mkdtempSync, rmSync } from 'node:fs'
    import { tmpdir } from 'node:os'
    import { join } from 'node:path'
    import Database from 'libsql'
    
    const dir = mkdtempSync(join(tmpdir(), 'libsql-busy-'))
    const path = join(dir, 'db.sqlite')
    
    function attempt(label, db, begin) {
      try {
        db.prepare(begin).run()
        db.prepare('SELECT count(*) FROM t').all()
        db.prepare('COMMIT').run()
        console.log(`${label}: ok`)
      } catch (e) {
        console.log(`${label}: FAILED ${e.code}: ${e.message}`)
        if (db.inTransaction) db.prepare('ROLLBACK').run()
      }
    }
    
    const holder = new Database(path)
    holder.exec('PRAGMA journal_mode=WAL')
    holder.exec('CREATE TABLE t (x INTEGER)')
    const victim = new Database(path)
    victim.exec('PRAGMA busy_timeout=50')
    
    attempt('0. control, before any failure, a write transaction on the victim connection', victim, 'BEGIN IMMEDIATE')
    
    holder.exec('BEGIN IMMEDIATE') // another connection holds the write lock
    try {
      victim.prepare('BEGIN IMMEDIATE').run() // fails at the busy timeout, as it should
      console.log('1. unexpected: the write lock was granted')
    } catch (e) {
      console.log(`1. the victim wants the write lock while it is held: ${e.code}: ${e.message}`)
    }
    holder.exec('ROLLBACK') // the lock is free from here on
    console.log(`   the victim connection reports inTransaction=${victim.inTransaction}`)
    
    attempt('2. read transaction on the victim connection, lock free', victim, 'BEGIN TRANSACTION READONLY')
    attempt('3. write transaction on the victim connection, lock free', victim, 'BEGIN IMMEDIATE')
    attempt('4. read transaction on a third connection', new Database(path), 'BEGIN TRANSACTION READONLY')
    attempt('5. write transaction on the lock holder connection', holder, 'BEGIN IMMEDIATE')
    
    if (globalThis.gc) {
      globalThis.gc()
      attempt('6. victim again, after gc() and no turn of the event loop', victim, 'BEGIN IMMEDIATE')
      for (let i = 0; i < 3; i++) {
        await new Promise((resolve) => setImmediate(resolve))
        globalThis.gc()
      }
      attempt('7. victim again, after gc() and turns of the event loop', victim, 'BEGIN IMMEDIATE')
    } else {
      console.log('6. and 7. skipped: run with --expose-gc to see the garbage collector end it')
    }
    rmSync(dir, { recursive: true, force: true })
    repro-client.mjs
    // The same defect through @libsql/client 0.15.15: a write batch that fails with SQLITE_BUSY
    // makes the next batches on that client fail at their COMMIT.
    // Run: node repro-client.mjs
    import { mkdtempSync, rmSync } from 'node:fs'
    import { tmpdir } from 'node:os'
    import { join } from 'node:path'
    import { createClient } from '@libsql/client'
    
    const dir = mkdtempSync(join(tmpdir(), 'libsql-client-busy-'))
    const url = `file:${join(dir, 'db.sqlite')}`
    
    async function attempt(label, call) {
      try {
        await call()
        console.log(`${label}: ok`)
      } catch (e) {
        console.log(`${label}: FAILED ${e.code}: ${e.message}`)
      }
    }
    
    const holderClient = createClient({ url })
    await holderClient.execute('PRAGMA journal_mode=WAL')
    await holderClient.execute('CREATE TABLE t (x INTEGER)')
    const victim = createClient({ url })
    await victim.execute('PRAGMA busy_timeout=50')
    const third = createClient({ url })
    
    const holder = await holderClient.transaction('write') // holds the write lock
    await attempt('1. write batch while the lock is held', () =>
      victim.batch(['INSERT INTO t VALUES (1)'], 'write'),
    )
    await holder.rollback() // the lock is free from here on
    await attempt('2. read batch on the same client, lock free', () =>
      victim.batch(['SELECT count(*) FROM t'], 'read'),
    )
    await attempt('3. write batch on the same client, lock free', () =>
      victim.batch(['INSERT INTO t VALUES (3)'], 'write'),
    )
    await attempt('4. read batch on a third client', () => third.batch(['SELECT count(*) FROM t'], 'read'))
    await attempt('5. a lone execute on the same client (no COMMIT of its own)', () =>
      victim.execute('SELECT count(*) FROM t'),
    )
    await attempt('6. a lone writing execute on the same client (autocommit)', () =>
      victim.execute('INSERT INTO t VALUES (6)'),
    )
    rmSync(dir, { recursive: true, force: true })
    repro-reset-control.mjs
    // Control: the statement object that failed, run again, is reset first by the binding, and
    // the connection is whole again with no garbage collection. So a reset after the failed step
    // is what is missing. Run: node repro-reset-control.mjs
    import { mkdtempSync, rmSync } from 'node:fs'
    import { tmpdir } from 'node:os'
    import { join } from 'node:path'
    import Database from 'libsql'
    
    const dir = mkdtempSync(join(tmpdir(), 'libsql-busy-control-'))
    const path = join(dir, 'db.sqlite')
    const holder = new Database(path)
    holder.exec('PRAGMA journal_mode=WAL')
    holder.exec('CREATE TABLE t (x INTEGER)')
    const victim = new Database(path)
    victim.exec('PRAGMA busy_timeout=50')
    
    holder.exec('BEGIN IMMEDIATE')
    const begin = victim.prepare('BEGIN IMMEDIATE')
    try {
      begin.run()
    } catch (e) {
      console.log(`1. first run of the statement: ${e.code}: ${e.message}`)
    }
    holder.exec('ROLLBACK')
    begin.run() // js_run resets the statement before it steps it again
    victim.prepare('INSERT INTO t VALUES (1)').run()
    victim.prepare('COMMIT').run()
    console.log('2. the same statement object run again, then INSERT and COMMIT: ok')
    rmSync(dir, { recursive: true, force: true })

    Output of node --expose-gc repro-binding.mjs:

    0. control, before any failure, a write transaction on the victim connection: ok
    1. the victim wants the write lock while it is held: SQLITE_BUSY: database is locked
       the victim connection reports inTransaction=false
    2. read transaction on the victim connection, lock free: FAILED SQLITE_BUSY: cannot commit transaction - SQL statements in progress
    3. write transaction on the victim connection, lock free: FAILED SQLITE_BUSY: cannot commit transaction - SQL statements in progress
    4. read transaction on a third connection: ok
    5. write transaction on the lock holder connection: ok
    6. victim again, after gc() and no turn of the event loop: FAILED SQLITE_BUSY: cannot commit transaction - SQL statements in progress
    7. victim again, after gc() and turns of the event loop: ok
    

    Cause, by file and line

    • SQLite, libsql-ffi-0.9.30/bundled/src/sqlite3.c. A statement that starts running is
      counted: db->nVdbeActive++; if( p->readOnly==0 ) db->nVdbeWrite++; (lines 92253-92254),
      and BEGIN IMMEDIATE is not read-only, because its OP_Transaction carries a write flag
      (line 86826). When OP_Transaction cannot get its lock it does not halt the statement. It
      saves the program counter and returns, so that the caller can step again:
      if( (rc&0xff)==SQLITE_BUSY ){ p->pc = ...; p->rc = rc; goto vdbe_return; } (lines
      98280-98284). The counts are given back only when the statement halts, which after this
      return means sqlite3_reset or sqlite3_finalize (lines 89404-89405). COMMIT refuses
      while any writing statement is counted: else if( desiredAutoCommit && db->nVdbeWrite>0 )
      with the message above and SQLITE_BUSY (lines 98177-98184).
    • The Rust crate, libsql-0.9.30/src/local/statement.rs lines 53-64: run binds, steps and
      on any code but DONE or ROW returns the error. It does not reset.
    • The binding, libsql-js src/statement.rs lines 78-91 (js_run): raw_stmt.reset() comes
      BEFORE raw_stmt.run(params), and when the run fails the function throws and returns. The
      same holds for js_get and the rows paths. A statement is finalized when its JavaScript
      object is collected (libsql-sys-0.9.30/src/statement.rs lines 22-35, Drop), and the
      binding offers JavaScript neither a reset nor a finalize.
    • The client, @libsql/client lib-esm/sqlite3.js lines 245-299 (executeStmt): every call
      prepares a new statement, runs it once and drops the reference, so the statement that
      failed is never run again and nothing but the collector ever resets it.

    Smallest fix

    Reset the statement when its step fails, in the binding (js_run, js_get, the rows paths
    and rowsNext) or one layer down in the crate's run, execute and query. better-sqlite3,
    whose API the binding follows, resets after every execution, failed or not. A reset of a
    statement that failed busy gives the counts back and changes nothing else.

    What a caller can do until then

    Replace the connection after a failed call (client.reconnect() on a file database), with
    care: a reconnect opens the client's path again, so a relative path opened before the process
    changed directory, a file removed or replaced while it was open, and an empty path (a private
    temporary database) each land on another database. Resolve the path first, check that the file
    is still the one that was open, and never reconnect a database that lives in its one
    connection: :memory:, an empty path. On 0.15 close the client before reconnecting, because a
    failed open otherwise leaves it holding a closed database, and reading inTransaction on a
    closed database aborts the process.

  3. antialias commented on Oct 30, 2026

    @antialias

    Also hitting this on @libsql/client 0.18.0 with libsql 0.5.29 (file:, WAL), behind a retry loop that waits out busy errors. One effect worth adding: a plain write can be lost silently, not only a later COMMIT failing.

    After a statement fails with SQLITE_BUSY, inTransaction still reads false, so ConnectionPool.release() puts the connection back and the pool hands it out next. A retried client.execute("INSERT …") then resolves, and the same client reads the row back. But it ran inside the failed statement's implicit transaction, so it never commits: other connections don't see it and can't write, and when GC finalizes the failed statement the write is rolled back. tursodatabase/libsql-js#245 shows the same at the binding level.

    Repro (client level)
    // node repro.mjs   (@libsql/client 0.18.0, libsql 0.5.29)
    import { createClient } from '@libsql/client';
    import Database from 'libsql';
    import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path';
    const file = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'busy-')), 'x.db');
    const setup = new Database(file); setup.exec('PRAGMA journal_mode=WAL; CREATE TABLE t (x)'); setup.close();
    
    const client = createClient({ url: `file:${file}`, timeout: 50 });
    const holder = new Database(file);
    holder.exec('BEGIN IMMEDIATE');
    await client.execute('INSERT INTO t VALUES (1)').catch((e) => console.log('1. execute:', e.code));
    holder.exec('COMMIT');
    
    await client.execute('INSERT INTO t VALUES (2)');
    console.log('2. client reads:', (await client.execute('SELECT x FROM t')).rows.map((r) => r.x));
    const other = new Database(file, { timeout: 0 });
    console.log('3. other reads:', other.prepare('SELECT x FROM t').all().map((r) => r.x));
    try { other.exec('INSERT INTO t VALUES (3)'); console.log('4. other writes: ok'); } catch (e) { console.log('4. other writes:', e.code); }
    
    const tx = await client.transaction('write').catch((e) => e);
    console.log('5. transaction:', tx instanceof Error ? tx.code : 'began');
    if (!(tx instanceof Error)) {
      await tx.execute('INSERT INTO t VALUES (4)');
      await tx.commit().then(() => console.log('6. commit: ok'), (e) => console.log('6. commit:', e.code, e.message));
    }
    client.close();

    Output:

    1. execute: SQLITE_BUSY
    2. client reads: [ 2 ]
    3. other reads: []
    4. other writes: SQLITE_BUSY
    5. transaction: began
    6. commit: SQLITE_BUSY SQLITE_BUSY: cannot commit transaction - SQL statements in progress
    

    With the connection closed on a busy error (below), lines 3, 4 and 6 read [ 2 ], ok and ok.

    The root fix looks like tursodatabase/libsql-js#238 (reset a statement after a failed step). Until that ships, we close the connection in the client on any busy error, so release() drops it. If a fix here takes that route, three places need it besides executeStmt()'s catch:

    1. executeMultiple()'s catch also just maps and rethrows.
    2. migrate()'s finally reads db.inTransaction without checking db.open. Once a busy error has closed the connection, that read aborts the process, as the comment in Sqlite3Transaction notes. release() also belongs in an inner finally, so the connection is released even when the ROLLBACK or the PRAGMA throws:
      finally {
          try {
              if (db.open && db.inTransaction) executeStmt(db, "ROLLBACK", this.#intMode);
              if (db.open) executeStmt(db, "PRAGMA foreign_keys=on", this.#intMode);
          } finally {
              this.#pool.release(db);
          }
      }
    3. The busy check should use the base code, (e.rawCode & 0xff) === 5, so extended codes such as SQLITE_BUSY_SNAPSHOT count too.
  4. Ken-Michi commented on Nov 10, 2026

    @Ken-Michi

    Adding how this shows up on @libsql/client 0.18.0, where the sqlite3 client now pools connections (#342).

    Because a statement that failed with SQLITE_BUSY stays "in progress" on its native connection (tursodatabase/libsql-js#240), and ConnectionPool.release() only checks db.inTransaction, the poisoned connection goes back to the idle list. With 0.18.0 the next transaction() usually gets the same connection back, so an application-level retry loop fails on every attempt:

    A begin ok
    B begin SQLITE_BUSY            <- B's BEGIN IMMEDIATE while A holds the write lock
    A commit ok
    B begin ok                     <- retry 1, same pooled connection
    B commit SQLITE_BUSY: cannot commit transaction - SQL statements in progress
    B begin ok                     <- retry 2, same pooled connection again
    B commit SQLITE_BUSY: cannot commit transaction - SQL statements in progress
    

    On 0.14.0 the first retry fails the same way, but the transaction takes the connection with it, so the second retry gets a fresh connection and succeeds. In our test (two clients on one WAL file, concurrent write transactions with retries), 0.14.0 failed 0/30 runs and 0.18.0 failed 30/30 (macOS, Node 24.22.1). Reads on the poisoned connection also keep the old snapshot until GC.

    The workaround we applied as a local patch of lib-esm/sqlite3.js and lib-cjs/sqlite3.js:

    1. In executeStmt / executeMultiple, when the mapped error code is SQLITE_BUSY or SQLITE_LOCKED, remember the connection in a WeakSet.
    2. In ConnectionPool.release(db), run the existing ROLLBACK first if db.inTransaction. Then, if the connection is in that set, or the ROLLBACK threw, close it instead of returning it to the pool. If a caller is waiting, give it a newly opened connection.

    The order matters: closing without the ROLLBACK while a stranded statement exists defers the real close, so the connection keeps its write lock until GC. With this patch, the 30-run test passes 30/30. A BEGIN IMMEDIATE that fails before any transaction starts is not fully covered when databases are ATTACHed: the main database lock stays held until GC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions