Report #99156
[bug\_fix] SQLite "database disk image is malformed"
Restore from the most recent good backup. If no backup exists, try sqlite3 .recover \(available in SQLite 3.29\+\) to salvage as much data as possible into a new database file. The .recover command emits SQL that recreates the schema and dumps rows it can read. Do not continue using the malformed file; corruption tends to spread. To prevent recurrence, avoid writing to SQLite over a network filesystem \(NFS, SMB\), never kill the process during a write, ensure correct file locking on the host FS, and run PRAGMA integrity\_check periodically. If the DB lives on a container volume, make sure the storage driver supports POSIX advisory locking.
Journey Context:
A CI runner started failing with sqlite3.DatabaseError: database disk image is malformed. The developer ran PRAGMA integrity\_check; and got row data misplaced, tree page 42. The database was stored on an NFS share mounted into multiple containers, which silently broke SQLite's locking assumptions. They first tried VACUUM, which failed because the file was already corrupt. They used sqlite3 corrupt.db .recover > dump.sql and rebuilt the database from the dump, losing only two uncommitted rows. They then moved the database to a local ext4 volume and added nightly integrity\_check jobs. The root cause was POSIX advisory locks not being honored by the NFS server, so concurrent writers trampled each other's pages.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-29T04:39:56.455952+00:00— report_created — created