SQLite 3: database is locked (SQLITE_BUSY) under concurrent writes
Error: database is locked
SQLite error: database is locked (5) while executing statement 'INSERT INTO events ...'
Immediate Remediation
bash
sqlite3 app.db 'PRAGMA journal_mode=WAL;' && echo 'PRAGMA busy_timeout=5000;' >> init.sql
Root Cause Analysis
SQLite only allows one writer at a time; with the default rollback journal, readers block writers and concurrent transactions exceed the default 0ms busy timeout, so the second writer immediately aborts with SQLITE_BUSY instead of waiting.
Verification & Guardrails
- WAL mode is persistent, but busy_timeout must be set per connection or in connection string (e.g. Python sqlite3.connect('file:app.db?mode=ro&busy_timeout=5000', uri=True)).
- WAL does not fix write serialization; long-running write transactions still starve other writers.
- On network filesystems (NFS) WAL may be unreliable; move to a local disk or a client-server DB.
Have a custom or uncategorized crash?
Run your trace through our in-memory client privacy sandbox for instant SRE remediation.