From b7bb583d8d6d2a299886449c12929d2dece5e67b Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Sun, 4 Feb 2024 10:42:48 -0800 Subject: [PATCH] fix: set durability for sqlite to recommended settings (#1667) Also do an optimize on connection close. Fixes lag on history insertion. --- atuin-client/src/database.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/atuin-client/src/database.rs b/atuin-client/src/database.rs index 19fccb0c..e67fe06d 100644 --- a/atuin-client/src/database.rs +++ b/atuin-client/src/database.rs @@ -14,7 +14,10 @@ use rand::{distributions::Alphanumeric, Rng}; use regex::Regex; use sql_builder::{esc, quote, SqlBuilder, SqlName}; use sqlx::{ - sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePool, SqlitePoolOptions, SqliteRow}, + sqlite::{ + SqliteConnectOptions, SqliteJournalMode, SqlitePool, SqlitePoolOptions, SqliteRow, + SqliteSynchronous, + }, Result, Row, }; use time::OffsetDateTime; @@ -137,6 +140,8 @@ impl Sqlite { let opts = SqliteConnectOptions::from_str(path.as_os_str().to_str().unwrap())? .journal_mode(SqliteJournalMode::Wal) + .optimize_on_close(true, None) + .synchronous(SqliteSynchronous::Normal) .create_if_missing(true); let pool = SqlitePoolOptions::new()