1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 15:32:43 +01:00

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().)
This commit is contained in:
Eelco Dolstra 2025-07-15 18:21:29 +02:00
parent dc77357e57
commit aff4ccd1a4

View file

@ -93,7 +93,7 @@ SQLite::~SQLite()
void SQLite::isCache() void SQLite::isCache()
{ {
exec("pragma synchronous = off"); exec("pragma synchronous = off");
exec("pragma main.journal_mode = truncate"); exec("pragma main.journal_mode = wal");
} }
void SQLite::exec(const std::string & stmt) void SQLite::exec(const std::string & stmt)