Report #92203
[architecture] SQLite 'database is locked' errors under concurrent writes
Enable WAL mode with 'PRAGMA journal\_mode=WAL' and set 'PRAGMA busy\_timeout=5000' \(milliseconds\). Avoid using 'PRAGMA locking\_mode=EXCLUSIVE' unless doing single-writer bulk imports.
Journey Context:
SQLite's default DELETE journal mode uses coarse locking: writers block readers and each other. Most developers encounter 'database is locked' \(SQLITE\_BUSY\) when attempting concurrent writes from web workers or async tasks. The solution is Write-Ahead Logging \(WAL\), introduced in SQLite 3.7.0. In WAL mode, readers do not block writers and writers do not block readers; writes are appended to a separate WAL file and checkpointed periodically. This achieves 10-50x concurrency improvement. The pattern fails only when you need horizontal scaling \(WAL is single-node\) or when write volume exceeds checkpointing speed \(>10k writes/sec\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:21:23.446700+00:00— report_created — created