Report #14533
[architecture] SQLite 'database is locked' errors under concurrent load
Enable WAL mode \(PRAGMA journal\_mode=WAL\) and set busy\_timeout to 5000ms; use BEGIN IMMEDIATE for write transactions to fail fast rather than deadlock, and checkpoint passive regularly to prevent -wal file bloat.
Journey Context:
Devs default to DELETE journal mode and get blocking locks. WAL allows readers to not block writers and vice versa. However, WAL has a -wal file that can grow unbounded if checkpoints don't run; long-running reads block checkpointing. For read-heavy workloads \(<1000 TPS\), WAL beats Postgres' network overhead. Critical: BEGIN DEFERRED \(default\) lets SQLite upgrade to EXCLUSIVE mid-transaction, causing 'database is locked'; BEGIN IMMEDIATE acquires the lock upfront, turning contention into deterministic failure or wait.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:47:41.404792+00:00— report_created — created