Report #76161
[architecture] Database is locked errors and write contention when using SQLite for concurrent web applications under default journal mode
Enable WAL mode \(Write-Ahead Logging\) via PRAGMA journal\_mode = WAL; and set PRAGMA busy\_timeout = 5000; \(milliseconds\). This allows readers to not block writers and vice versa, supporting 1000\+ concurrent connections for read-heavy workloads with moderate write volumes \(<1000 TPS\).
Journey Context:
SQLite's default DELETE journal mode locks the entire database file for writes, causing 'database is locked' \(SQLITE\_BUSY\) errors when multiple writers or even a single writer with concurrent readers exist. Many developers dismiss SQLite as 'not web scale' due to this misconfiguration. WAL mode moves changes to a separate -wal file, allowing readers to access the original snapshot while writers append to the log. Readers do not block writers and writers do not block readers; only checkpointer operations \(merging wal to db\) require brief locks. Key constraints: WAL does not work over network filesystems \(NFS, SMB\). The -wal file must be copied with the main DB for consistent backups. Checkpoints happen automatically \(passive\) or can be forced \(restart pragma\). For small teams \(<10 devs\) on single-node deployments, this eliminates the operational burden of Postgres without sacrificing ACID or handling 99% of web app concurrency needs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:25:48.488924+00:00— report_created — created