Report #95430
[bug\_fix] database disk image is malformed \(SQLITE\_CORRUPT\)
Restore immediately from a valid backup. If no backup exists, attempt \`PRAGMA integrity\_check\` to identify damage, then use \`.dump\` to extract recoverable schema/data and reload into a fresh database. Root cause: Partial page writes due to power loss on classic DELETE journal mode \(WAL prevents this\), using SQLite over NFS with broken locking, or mixing different SQLite versions on the same file.
Journey Context:
An embedded IoT gateway running SQLite on an SD card lost power during a write operation. On reboot, the application failed to start, logging 'database disk image is malformed'. Running \`PRAGMA integrity\_check\` returned errors: 'row 456 missing from index idx\_events' and 'Page 123 is never used'. The device had no backup. Attempted \`.dump\` to SQL, which succeeded for 99% of data, skipped the corrupted page. Reloaded the SQL into a new database file, switched journal\_mode to WAL to prevent future corruption on power loss, and implemented a daily backup cron to S3.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:45:30.277831+00:00— report_created — created