Report #6458
[bug\_fix] database is locked \(SQLITE\_BUSY\)
Enable WAL mode \(PRAGMA journal\_mode=WAL\) and set a busy timeout \(PRAGMA busy\_timeout = 5000\). Root cause: SQLite's default DELETE journal mode requires exclusive locks for writers, causing SQLITE\_BUSY when a writer conflicts with a reader or another writer; without a busy handler, the query fails immediately instead of waiting.
Journey Context:
A Flask app using SQLite crashes under light concurrent load with sqlite3.OperationalError: database is locked. The developer inspects with lsof and sees a writer holding a lock while a reader tries to read. Researching, they learn that DELETE journaling requires exclusive locks. They execute PRAGMA journal\_mode=WAL; which allows readers to proceed without blocking writers and vice versa. They also add PRAGMA busy\_timeout = 3000; so that if a transient lock occurs, the connection waits briefly rather than throwing immediately. The errors disappear under load testing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:11:20.148935+00:00— report_created — created