Skip to content

Commit 91a4cb4

Browse files
committed
feat: Disable wal_autocheckpoint
From https://www.sqlite.org/wal.html: > The default strategy is to allow successive write transactions to grow the WAL until the WAL becomes about 1000 pages in size, then to run a checkpoint operation for each subsequent COMMIT until the WAL is reset to be smaller than 1000 pages. By default, the checkpoint will be run automatically by the same thread that does the COMMIT that pushes the WAL over its size limit. This has the effect of causing most COMMIT operations to be very fast but an occasional COMMIT (those that trigger a checkpoint) to be much slower. And while autocheckpoint runs in the `PASSIVE` mode and thus doesn't block concurrent readers and writers, in our design it blocks writers because it's done under `write_mutex` locked and thus may cause the app to stuck for noticeable time. Let's disable autocheckpointing then, we can't rely on it anyway.
1 parent b696a24 commit 91a4cb4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/sql.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ fn new_connection(path: &Path, passphrase: &str) -> Result<Connection> {
729729
PRAGMA busy_timeout = 0; -- fail immediately
730730
PRAGMA soft_heap_limit = 8388608; -- 8 MiB limit, same as set in Android SQLiteDatabase.
731731
PRAGMA foreign_keys=on;
732+
PRAGMA wal_autocheckpoint=N;
732733
",
733734
)?;
734735

0 commit comments

Comments
 (0)