Report #39483
[bug\_fix] database is locked \(SQLITE\_BUSY\) in SQLite
Execute \`PRAGMA journal\_mode=WAL;\` to enable Write-Ahead Logging \(allows concurrent reads during writes\), AND execute \`PRAGMA busy\_timeout = 5000;\` \(or higher\) to make connections wait for locks instead of immediately returning SQLITE\_BUSY.
Journey Context:
A developer builds an internal tool using Python and SQLite. It works perfectly in development with a single user. Upon deployment to a small team server with 5 concurrent users, the application starts throwing "database is locked" errors intermittently. The developer discovers that SQLite's default journal mode is DELETE \(rollback journal\), which requires exclusive locks for writes, and the default busy timeout is 0, meaning writers immediately fail if the database is locked. The rabbit hole leads to the SQLite documentation on Write-Ahead Logging \(WAL mode\), which allows readers to continue operating while a writer is active, and the busy\_timeout pragma which makes SQLite sleep and retry rather than failing immediately. After switching to WAL mode and setting a 5-second busy timeout, the concurrency errors disappear without changing the application logic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:44:43.375071+00:00— report_created — created