Skip to content

Commit

Permalink
fix: set durability for sqlite to recommended settings (#1667)
Browse files Browse the repository at this point in the history
Also do an optimize on connection close. Fixes lag on history insertion.
  • Loading branch information
nebkor committed Feb 4, 2024
1 parent c2af6f7 commit b7bb583
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion atuin-client/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit b7bb583

Please sign in to comment.