From 25480e837f1b11e4ddc7d22114b004c7d84a7292 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Thu, 22 Dec 2022 16:10:49 -0600 Subject: [PATCH] fix: do not block writers for more than 1 second during checkpoints --- src/db.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/db.rs b/src/db.rs index b3cb497..a224231 100644 --- a/src/db.rs +++ b/src/db.rs @@ -689,8 +689,10 @@ pub async fn db_maintenance(pool: SqlitePool) { tokio::select! { _ = tokio::time::sleep(Duration::from_secs(EVENT_MAINTENANCE_FREQ_SEC)) => { if let Ok(mut conn) = pool.get() { - // set the busy timeout to a larger value (default is 5 seconds). - conn.busy_timeout(Duration::from_secs(60)).ok(); + // the busy timer will block writers, so don't set + // this any higher than you want max latency for event + // writes. + conn.busy_timeout(Duration::from_secs(1)).ok(); debug!("running database optimizer"); optimize_db(&mut conn).ok(); debug!("running wal_checkpoint(TRUNCATE)");