diff options
author | jade <lix@jade.fyi> | 2024-05-31 19:21:30 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@lix-systems> | 2024-05-31 19:21:30 +0000 |
commit | 7081889faa76c64990c4347f64d3cc2a21f565f4 (patch) | |
tree | 76bc001c2ca855ff16d006df03ae1a397dbaabf3 /src | |
parent | adedac70fad1f5b6e11d1ac5d4a18ede57830654 (diff) | |
parent | 713cd7e9e7012a11d2347e9b1a5dee9b4d3c62c0 (diff) |
Merge "truncate WAL files on exit" into main
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/local-store.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 7bcbe3298..d92fafa1b 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -550,7 +550,12 @@ void LocalStore::openDB(State & state, bool create) if (mode == "wal" ) { /* persist the WAL files when the DB connection is closed. * This allows for read-only connections without any write permissions - * on the state directory to succeed on a closed database. */ + * on the state directory to succeed on a closed database. Setting the + * journal_size_limit to 2^40 bytes results in the WAL files getting + * truncated to 0 on exit and limits the on disk size of the WAL files + * to 2^40 bytes following a checkpoint */ + if (sqlite3_exec(db, "pragma main.journal_size_limit = 1099511627776;", 0, 0, 0) != SQLITE_OK) + SQLiteError::throw_(db, "setting journal_size_limit"); int enable = 1; if (sqlite3_file_control(db, NULL, SQLITE_FCNTL_PERSIST_WAL, &enable) != SQLITE_OK) SQLiteError::throw_(db, "setting persistent WAL mode"); |