From f3afe7b02ae55f8a9cd28c50335453b5b2b4d59f Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Mon, 2 Mar 2026 16:26:23 +0100 Subject: [PATCH] radicle/config/sqlite: Use `synchronous = NORMAL` Change the default value for the `synchronous` pragma from `FULL` to `NORMAL`. With this change, SQLite will not aggressively `fsync()` after every transaction, so there is considerably less disk pressure as disk I/O can be batched. See : > `WAL` mode is safe from corruption with `synchronous=NORMAL`, and > probably `DELETE` mode is safe too on modern filesystems. `WAL` mode is > always consistent with `synchronous=NORMAL`, but `WAL` mode does lose > durability. A transaction committed in `WAL` mode with > `synchronous=NORMAL` might roll back following a power loss or system > crash. > Transactions are durable across application crashes regardless of the > synchronous setting or journal mode. Also: > You lose durability across power lose with synchronous `NORMAL` in `WAL` > mode, but that is not important for most applications. Transactions > are still atomic, consistent, and isolated, which are the most > important characteristics in most use cases. So, there is no risk of database corruption, and in the extreme cases of sudden power loss or system crash, some transaction may roll back. See also Co-authored-by: Yorgos Saslis --- crates/radicle/CHANGELOG.md | 5 +++++ crates/radicle/src/node/db/config.rs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/radicle/CHANGELOG.md b/crates/radicle/CHANGELOG.md index d5dad941..379b3717 100644 --- a/crates/radicle/CHANGELOG.md +++ b/crates/radicle/CHANGELOG.md @@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- The default configuration for the SQLite pragma `synchronous` is changed + from `FULL` to `NORMAL`, which generates less I/O operations. On power + loss, transactions might be rolled back, but SQLite still guarantees + consistency in this mode. + ### Removed ### Security diff --git a/crates/radicle/src/node/db/config.rs b/crates/radicle/src/node/db/config.rs index c57e80c6..f3d030b4 100644 --- a/crates/radicle/src/node/db/config.rs +++ b/crates/radicle/src/node/db/config.rs @@ -1,7 +1,7 @@ use super::sqlite_ext::*; const DEFAULT_JOURNAL_MODE: JournalMode = JournalMode::WAL; -const DEFAULT_SYNCHRONOUS: Synchronous = Synchronous::FULL; +const DEFAULT_SYNCHRONOUS: Synchronous = Synchronous::NORMAL; /// Database configuration. #[derive(Debug, Default, Copy, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize)] @@ -88,7 +88,7 @@ mod test { #[test] fn database_config_valid_combinations() { let cases = [ - (None, None, JournalMode::WAL, Synchronous::FULL), + (None, None, JournalMode::WAL, Synchronous::NORMAL), ( Some("WAL"), Some("NORMAL"),