Report #97745
[bug\_fix] SQLite: database disk image is malformed
First identify whether the file is actually corrupt or merely mismatched \(e.g. opening a WAL-mode database with a read-only connection or an older SQLite build\). If corrupt, restore from the most recent backup; SQLite does not provide a repair tool. You can attempt to salvage data with .mode insert and .dump on a clone, but any recovered dump may be partial. Prevent recurrence by avoiding network filesystems, killing processes while writes are in flight, and never calling fsck or copy utilities on a live SQLite file. Use PRAGMA integrity\_check after incidents.
Journey Context:
An agent stores state in a SQLite file on a Docker volume backed by a cloud-provider network filesystem. After a host restart, every query returns "database disk image is malformed". SQLite's PRAGMA integrity\_check reports btree errors. The agent tries VACUUM and REINDEX, but both error out because the underlying pages are damaged. Howtocorrupt.html explains that advisory locking on many network filesystems is unreliable, so two containers can write overlapping pages. Recovery means restoring the nightly backup and moving the database to a local volume; the agent also adds periodic .backup copies because SQLite has no built-in repair command.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-26T04:37:55.603344+00:00— report_created — created