mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-21 05:54:20 +01:00
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 <rusty@rustcorp.com.au> Changelog-Changed: db: we now set a busy timeout to safely allow others to access sqlite3 db (e.g. litestream)
This commit is contained in:
@@ -43,6 +43,11 @@ static bool db_sqlite3_setup(struct db *db)
|
||||
}
|
||||
db->conn = sql;
|
||||
|
||||
/* In case another writer (litestream?) grabs a lock, we don't
|
||||
* want to return SQLITE_BUSY immediately (which will cause a
|
||||
* fatal error): give it 5 seconds. */
|
||||
sqlite3_busy_timeout(db->conn, 5000);
|
||||
|
||||
sqlite3_prepare_v2(db->conn, "PRAGMA foreign_keys = ON;", -1, &stmt, NULL);
|
||||
err = sqlite3_step(stmt);
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
Reference in New Issue
Block a user