Report #97196
[bug\_fix] SQLite database is locked \(SQLITE\_BUSY\)
Enable WAL mode with PRAGMA journal\_mode=WAL on every connection, set PRAGMA busy\_timeout=5000 so writers wait instead of failing immediately, keep write transactions short, and serialize writes at the application level. Avoid placing the database file on NFS or SMB, where file locking is unreliable.
Journey Context:
A small Python daemon used SQLite for job queue state. Under load it started throwing sqlite3.OperationalError: database is locked. The developer inspected the connection with PRAGMA journal\_mode and saw delete, and PRAGMA busy\_timeout returned 0. In rollback-journal mode each write needs an exclusive lock on the whole file, and with no busy timeout any contention immediately surfaced as SQLITE\_BUSY. They added a connect-time listener that executed PRAGMA journal\_mode=WAL and PRAGMA busy\_timeout=5000, and moved long reads outside transactions. Lock errors dropped to zero because WAL allows concurrent readers during a write and busy\_timeout lets writers queue briefly instead of erroring.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T04:42:35.722600+00:00— report_created — created