From 349d2c58e579ddd2e423a8a111d4e9cb102e7a1b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 15 Jul 2025 18:21:29 +0200 Subject: [PATCH] Use WAL mode for SQLite cache databases With "truncate" mode, if we try to write to the database while another process has an active write transaction, we'll block until the other transaction finishes. This is a problem for the evaluation cache in particular, since it uses long-running transactions. WAL mode does not have this issue: it just returns "busy" right away, so Nix will print error (ignored): SQLite database '/home/eelco/.cache/nix/eval-cache-v5/...' is busy and stop trying to write to the evaluation cache. (This was the intended/original behaviour, see AttrDb::doSQLite().) --- src/libstore/sqlite.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstore/sqlite.cc b/src/libstore/sqlite.cc index dd9f10422..41c9f9e7d 100644 --- a/src/libstore/sqlite.cc +++ b/src/libstore/sqlite.cc @@ -99,7 +99,7 @@ SQLite::~SQLite() void SQLite::isCache() { exec("pragma synchronous = off"); - exec("pragma main.journal_mode = truncate"); + exec("pragma main.journal_mode = wal"); } void SQLite::exec(const std::string & stmt)