Report #103419
[bug\_fix] SQLite database is locked under concurrent writes
Enable WAL mode \(PRAGMA journal\_mode=WAL\) and set a reasonable busy timeout \(PRAGMA busy\_timeout=5000\). If the app has many writers, serialize write access through a single writer thread or connection instead of letting multiple connections contend for the write lock.
Journey Context:
A small service using SQLite started throwing database is locked errors as soon as two workers tried to write at the same time. The first attempt was to increase the busy timeout, but with the default rollback journal, a long-running read transaction still blocked all writers, so writes timed out. Switching to WAL mode let readers proceed without blocking writers and writers proceed without blocking readers, which reduced lock contention dramatically. Then a single writer connection with busy\_timeout=5000ms handled all mutations, while read replicas used separate connections. The errors stopped because WAL mode separates reads and writes at the lock level, and the busy timeout gave the single writer time to wait for any brief contention rather than failing immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-11T04:22:12.368648+00:00— report_created — created