[Bug] queue.db SQLite auto_vacuum=OFF by default — grows to 462MB with 0 pending messages
Bug Description
The QueueFS SQLite database (_system/queue/queue.db) defaults to auto_vacuum=OFF. When messages are consumed and deleted from the queue, the space is never reclaimed — the file grows monotonically.
Issue #2707 reported this and was closed, but the auto_vacuum setting is still OFF by default in the current release. The issue appears to have been partially addressed (version cleanup) but the core SQLite VACUUM problem persists.
Observed Data
| Metric | Value |
|---|---|
| queue.db file size | 462 MB |
| Total pages | 118,439 |
| Freelist pages | 118,432 (99.99% free) |
| Actual data | 7 pages ≈ 28 KB |
queue_messages table rows |
0 (queue is empty) |
PRAGMA auto_vacuum |
0 (OFF) |
The database is 462MB but contains less than 28KB of actual data. Every byte of the 462MB is wasted space from processed-and-deleted queue messages.
Impact
- Disk waste: 462MB of pure dead space per OV instance
- Memory waste: SQLite may cache portions of the oversized file
- Startup latency: Scanning a 462MB file at startup is unnecessary
- Backups: The file is included in backups, inflating backup size by 462MB
Workaround Applied
We added a cron job (0 4 1 * *) to run sqlite3 queue.db "VACUUM;" monthly. This works but is a manual workaround.
Expected Behavior
The QueueFS should either:
- Set
auto_vacuum=INCREMENTALat database creation time, and runPRAGMA incremental_vacuumperiodically - Or run
VACUUMautomatically after consuming batches of messages - Or expose a config option
queue.vacuum_intervalfor scheduled compaction
Environment
- OpenViking: 0.4.5+
- Storage: Local VikingFS, SQLite QueueFS
- Deployment: single-node, ~2 months uptime
- queue.db: 462MB / 28KB actual data
Thanks for reporting this, and for including the page/freelist numbers.
We checked the current QueueFS SQLite path. New queue databases created by recent builds do enable SQLite auto-vacuum during initialization: the backend sets PRAGMA auto_vacuum=FULL and runs VACUUM before creating the queue tables. That fix was added in #2754.
The gap here is existing/legacy queue.db files. The current migration path intentionally does not rewrite an already-created SQLite database whose auto_vacuum is OFF, because changing that mode requires a VACUUM and can be expensive/blocking and require extra free disk space. As a result, an older queue.db can keep its large freelist after upgrading, even when the queue is empty.
For the affected instance, the safe manual maintenance path is to stop OpenViking, make sure there is enough free disk space, then run something equivalent to:
sqlite3 _system/queue/queue.db "PRAGMA auto_vacuum=FULL; VACUUM;"
After that, the database should both shrink and keep reclaiming pages going forward.
I think we should keep this issue open as an upgrade/maintenance gap rather than treating it as a new-database default regression. A small, explicit maintenance command or documented migration step is probably safer than running VACUUM automatically on every startup.