Report #49104
[bug\_fix] SQLITE\_BUSY \(database is locked\)
Enable WAL mode via PRAGMA journal\_mode=WAL; and set a busy timeout via PRAGMA busy\_timeout=5000; \(milliseconds\). Root cause: SQLite's default DELETE journal mode requires exclusive locks for writes; concurrent write attempts fail immediately with BUSY. WAL mode allows concurrent reads during writes and uses shared locks, while busy\_timeout enables automatic retrying instead of immediate failure.
Journey Context:
Flask web application with gunicorn workers started throwing 'database is locked' errors under moderate load \(10 concurrent users\). Default journal\_mode was DELETE. When two requests tried to write simultaneously, one got the exclusive lock and the other immediately received SQLITE\_BUSY. Switched to WAL mode using PRAGMA journal\_mode=WAL; which allows readers to proceed during writes. Added PRAGMA busy\_timeout=5000 to handle the rare case where two writers collide, causing SQLite to retry for 5 seconds before returning BUSY. Errors disappeared immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:54:20.414023+00:00— report_created — created