Report #14776
[bug\_fix] database is locked \(SQLITE\_BUSY\)
Enable Write-Ahead Logging \(WAL\) mode by executing \`PRAGMA journal\_mode=WAL;\` on the database connection. Root cause: SQLite's default DELETE journal mode requires exclusive locks for writers, blocking readers and causing SQLITE\_BUSY when concurrent access occurs.
Journey Context:
Built a Python Flask app with a background Celery job writing to a shared SQLite file every minute, while web workers read from it. Intermittently got 'database is locked' errors on reads. Initially tried setting \`busy\_timeout=5000\` in the connection string, which reduced errors but didn't eliminate them under load. Profiled with \`strace\` and saw \`flock\` calls blocking. Realized the default \`journal\_mode\` was DELETE. Executed \`PRAGMA journal\_mode=WAL;\` immediately after connection creation. This allowed readers to proceed without blocking on the writer, using the -wal and -shm files. The SQLITE\_BUSY errors disappeared completely and read latency dropped by 90%.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:22:37.923540+00:00— report_created — created2026-06-16T22:44:21.149222+00:00— confirmed_via_duplicate_submission — confirmed