taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit f4e33f3904fab77b66325d970f2b953f26232855
parent e733615bc0b754c25215409e299d0e04364e19d7
Author: Florian Dold <dold@taler.net>
Date:   Mon, 20 Jul 2026 00:08:45 +0200

db: set busy_timeout on the native sqlite connection

Without it, a lock held by another connection surfaces as immediate
SQLITE_BUSY.

Diffstat:
Mpackages/taler-wallet-core/src/dbtx-sqlite.ts | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/packages/taler-wallet-core/src/dbtx-sqlite.ts b/packages/taler-wallet-core/src/dbtx-sqlite.ts @@ -178,8 +178,21 @@ export class SqliteTxControl { } } +/** + * How long to wait for a lock held by another connection before giving up. + * + * Without this a concurrent writer surfaces as an immediate SQLITE_BUSY. + * Within one process TxQueue serialises transactions so it cannot happen, but + * nothing stops a second process -- a CLI command run against a wallet the + * shepherd has open, say -- from touching the same file. Five seconds is long + * enough to outlast any transaction this code issues and short enough that a + * genuine deadlock still surfaces as an error rather than a hang. + */ +const SQLITE_BUSY_TIMEOUT_MS = 5000; + export async function initSqliteWalletDb(db: Sqlite3Database): Promise<void> { await db.exec("PRAGMA foreign_keys = ON"); + await db.exec(`PRAGMA busy_timeout = ${SQLITE_BUSY_TIMEOUT_MS}`); // WAL: readers do not block the writer, and a commit appends to the log // instead of fsyncing the whole database. //