Report #100542
[bug\_fix] SQLite: database disk image is malformed
Stop all writes, run PRAGMA integrity\_check to confirm corruption, then dump the database with .dump and reload it into a fresh file. Identify the root cause \(unclean shutdown, filesystem/NFS issue, or concurrent writers\) before returning the new database to service.
Journey Context:
A long-running SQLite database used by a background worker suddenly starts returning 'database disk image is malformed' on queries. The team first tries VACUUM, but SQLite refuses because it cannot parse the btree. PRAGMA integrity\_check reports multiple 'row missing from index' and 'wrong \# of entries in index' errors. The SQLite docs state that this error means the on-disk structure is no longer valid, usually from an unclean shutdown, hardware failure, or writing from two processes that do not share a lock \(for example over NFS\). Because the database file itself contains invalid pages, there is no safe in-place repair. The established recovery path is to dump the still-readable data with the sqlite3 .dump command, inspect the dump for obvious truncation, and load it into a brand-new file. The underlying cause—an unstable network filesystem in this case—is removed so the corruption does not recur.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-02T04:41:09.611952+00:00— report_created — created