Report #3774
[bug\_fix] database is locked \(SQLITE\_BUSY\) in SQLite
Enable Write-Ahead Logging \(WAL\) mode via \`PRAGMA journal\_mode=WAL;\` to allow concurrent readers and a single writer without blocking.
Journey Context:
A Flask application running under Gunicorn with 4 workers suddenly throws 'database is locked' errors under moderate POST load. Investigation with \`lsof\` shows multiple processes holding exclusive locks on the database file. The default DELETE journal mode uses POSIX advisory locks, causing writers to block each other aggressively. The rabbit-hole includes trying \`PRAGMA busy\_timeout=5000\`, which merely retries and fails under sustained load. The definitive fix switches the database to WAL mode, which separates reads from writes via a shared memory index \(-shm file\) and append-only log \(-wal file\), allowing the application to handle hundreds of concurrent reads during a single write without a single 'database is locked' error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:12:03.741575+00:00— report_created — created