Report #93556
[bug\_fix] SQLite WAL file growing indefinitely \(-wal file huge\)
Ensure no long-running read transactions hold back the checkpoint, and run PRAGMA wal\_checkpoint\(TRUNCATE\) periodically \(or during maintenance windows\) to reset the WAL file, combined with keeping read transactions as short as possible.
Journey Context:
A desktop application users reported that the database file was 50MB but there was a 2GB .sqlite-wal file alongside it, consuming excessive disk space. The app used WAL \(Write-Ahead Logging\) mode for better concurrency. Investigation showed that the app opened a read transaction at startup to cache some reference data and kept it open for the entire application lifetime. In WAL mode, a checkpoint operation \(which moves data from the WAL to the main database and truncates the WAL\) cannot truncate past the point of the oldest active reader. Because the app held a read snapshot open indefinitely, the WAL file grew monotonically with every write operation, never being truncated. The fix required restructuring the app to use short-lived read transactions \(open, query, close immediately\). Additionally, the app now runs PRAGMA wal\_checkpoint\(TRUNCATE\) during its nightly maintenance routine after ensuring all long reads are closed, which forces the WAL to be truncated regardless of size, reclaiming disk space immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:37:09.511302+00:00— report_created — created