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 <https://sqlite.org/pragma.html>:
> `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 <https://sqlite.org/wal.html>

Co-authored-by: Yorgos Saslis <yorgos.work@proton.me>
This commit is contained in:
Lorenz Leutgeb 2026-03-02 16:26:23 +01:00 committed by Fintan Halpenny
parent f4aee203ab
commit f3afe7b02a
2 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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"),