Skip to content

Commit 5bf2b5c

Browse files
committed
wallet: set a timeout if the db is busy.
This is recommended for litestream, which allows for easy async backup, and harmless otherwise. Signed-off-by: Rusty Russell <[email protected]> Changelog-Changed: db: we now set a busy timeout to safely allow others to access sqlite3 db (e.g. litestream)
1 parent c066378 commit 5bf2b5c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

wallet/db_sqlite3.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ static bool db_sqlite3_setup(struct db *db)
4343
}
4444
db->conn = sql;
4545

46+
/* In case another writer (litestream?) grabs a lock, we don't
47+
* want to return SQLITE_BUSY immediately (which will cause a
48+
* fatal error): give it 5 seconds. */
49+
sqlite3_busy_timeout(db->conn, 5000);
50+
4651
sqlite3_prepare_v2(db->conn, "PRAGMA foreign_keys = ON;", -1, &stmt, NULL);
4752
err = sqlite3_step(stmt);
4853
sqlite3_finalize(stmt);

0 commit comments

Comments
 (0)