News for hackers. Stuff that matters.
Re:SQLite in Production: Optimizing WAL Mode, Concurrency, a... by tnodir on Wednesday July 29, 2026 @09:18AM (#49097135)
> PRAGMA synchronous = NORMAL;

> In NORMAL mode, the database engine syncs to disk only at critical moments (e.g., during checkpoints) rather than at every single transaction commit. In WAL mode, this is completely safe from database corruption; even if the server crashes, only the uncommitted transactions in the WAL are lost, but the database integrity remains intact.

No, this is not safe. You can lose the latest committed transaction with this pragma.

Re:SQLite in Production: Optimizing WAL Mode, Concurrency, a... by JSR_FDED on Wednesday July 29, 2026 @09:57AM (#49097623)
Safe in this context means not corrupting the database. You might lose data, but the database will live on happily as if the missing data was never written to it. You don’t get half-committed transactions, and the database isn’t in a weird state.
Re:SQLite in Production: Optimizing WAL Mode, Concurrency, a... by tnodir on Wednesday July 29, 2026 @10:18AM (#49097884)
> even if the server crashes, only the uncommitted transactions in the WAL are lost

I'm mainly referring to this quote.

So, you can lose committed transactions too.

Re:SQLite in Production: Optimizing WAL Mode, Concurrency, a... by lazyant on Wednesday July 29, 2026 @09:38AM (#49097365)
I lost rows in a busy table until I changed to PRAGMA synchronous = FULL
Re:SQLite in Production: Optimizing WAL Mode, Concurrency, a... by chasil on Wednesday July 29, 2026 @01:20PM (#49100338)
Then WAL mode is not safe for you.

"Transactions involving multiple attached databases are atomic, assuming that the main database is not ":memory:" and the journal_mode is not WAL. If the main database is ":memory:" or if the journal_mode is WAL, then transactions continue to be atomic within each individual database file. But if the host computer crashes in the middle of a COMMIT where two or more database files are updated, some of those files might get the changes where others might not."

https://sqlite.org/lang_attach.html