From: Steve Myers Date: Sat, 15 Feb 2025 04:55:06 +0000 (-0600) Subject: fix(sqlite): set connection journal_mode to WAL and busy_timeout to 5000 ms X-Git-Tag: v0.30.2^2~1 X-Git-Url: http://internal-gitweb-vhost/?a=commitdiff_plain;h=10655114e829d4d196c7aca0e5780af7ad1595b9;p=bdk fix(sqlite): set connection journal_mode to WAL and busy_timeout to 5000 ms This prevents: Error { code: DatabaseBusy, extended_code: 5 }, Some("database is locked") which occured when syncing very large number of utxos. See: electrum::test::test_electrum_large_num_utxos --- diff --git a/src/database/sqlite.rs b/src/database/sqlite.rs index 59ce8985..a6047b1d 100644 --- a/src/database/sqlite.rs +++ b/src/database/sqlite.rs @@ -86,7 +86,13 @@ impl SqliteDatabase { /// Instantiate a new SqliteDatabase instance by creating a connection /// to the database stored at path pub fn new>(path: T) -> Self { - let connection = get_connection(&path).unwrap(); + let connection = get_connection(&path).expect("Failed to open database"); + connection + .execute_batch("PRAGMA journal_mode = WAL") + .expect("Failed to set WAL journal mode"); + connection + .execute_batch("PRAGMA busy_timeout = 5000") + .expect("Failed to set busy_timeout"); SqliteDatabase { path: PathBuf::from(path.as_ref()), connection,