Report #35226
[bug\_fix] SQLite WAL file grows unbounded / checkpoint starvation
Ensure long-running read transactions are committed promptly to allow the automatic checkpoint to truncate the -wal file; manually run PRAGMA wal\_checkpoint\(TRUNCATE\) during maintenance windows if necessary.
Journey Context:
A Node.js analytics service using SQLite WAL mode runs for days. The database file remains 200MB, but the accompanying -wal file grows to 5GB, consuming disk space and gradually degrading read performance. Checking PRAGMA wal\_checkpoint; returns busy. Investigation reveals a long-running read-only transaction opened by a nightly reporting job, which holds back the checkpoint. In WAL mode, the checkpoint process cannot truncate the -wal file until all existing read transactions complete, as they may need to read from the -wal. The immediate fix is to ensure the reporting job uses short transactions or runs against a replica/snapshot. The permanent operational fix is to monitor the -wal file size and, during low-traffic maintenance windows, execute PRAGMA wal\_checkpoint\(TRUNCATE\); which forces a checkpoint and resets the WAL file, reclaiming disk space. Adjusting wal\_autocheckpoint \(default 1000 pages\) may also help tune frequency.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:35:55.070711+00:00— report_created — created