Report #62732
[bug\_fix] database is locked \(SQLITE\_BUSY\)
Enable Write-Ahead Logging \(WAL\) mode using PRAGMA journal\_mode=WAL; or implement exponential backoff retry logic with sqlite3\_busy\_timeout\(\). Root cause: SQLite's legacy rollback journal requires exclusive locks for writes, causing SQLITE\_BUSY when readers block writers or concurrent writers contend.
Journey Context:
Your Python Flask app uses SQLite for a small analytics service. Under load, you see 'sqlite3.OperationalError: database is locked' sporadically. You check the code and see concurrent threads trying to write metrics. You try setting sqlite3\_busy\_timeout\(5000\) but errors persist under heavy load. You examine the database with PRAGMA journal\_mode; and see 'delete' \(rollback journal\). You realize that in rollback journal mode, a writer needs an exclusive lock on the entire database file, and any long-running read transaction blocks it. You execute PRAGMA journal\_mode=WAL; and the locking errors disappear because WAL allows readers to proceed without blocking writers and vice versa, though you now need to manage checkpointing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:46:40.636038+00:00— report_created — created