Report #3853
[architecture] SQLite 'database is locked' errors under concurrent web traffic
Enable Write-Ahead Logging mode immediately on every connection: execute 'PRAGMA journal\_mode=WAL;' on database initialization. This allows readers to proceed without blocking writers and prevents the 'database is locked' \(SQLITE\_BUSY\) errors common in web apps.
Journey Context:
By default, SQLite uses rollback journals which require exclusive locks for any write, blocking all readers and other writers. Developers often conclude SQLite 'cannot handle concurrency' and migrate unnecessarily to PostgreSQL. WAL mode decouples reading from writing by appending changes to a separate -wal file; readers see a snapshot of the database as of the beginning of their query. Tradeoffs: WAL mode requires the -wal and -shm files to exist on the same filesystem \(no NFS\), and you must periodically run 'PRAGMA wal\_checkpoint' to avoid unbounded disk growth. It is strictly superior for web workloads with read-heavy traffic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:20:05.077424+00:00— report_created — created