Report #75773
[bug\_fix] SQLITE\_BUSY: database is locked
Enable Write-Ahead Logging \(WAL\) mode via PRAGMA journal\_mode=WAL; concurrent reads no longer block writes. Additionally, set PRAGMA busy\_timeout = 5000; to make threads wait gracefully for locks instead of failing immediately.
Journey Context:
Electron desktop app or Python web service using SQLite crashes under concurrent writes with 'database is locked'. Default journal\_mode=DELETE uses a single writer model; when one process writes, it gets an exclusive lock on the entire database file, blocking readers and other writers. Debugging involved checking journal\_mode and observing that multiple threads were hitting the db simultaneously. The fix transitioned the database to WAL mode, where readers use old snapshots while writers append to the WAL file, allowing concurrent reads during writes. Adding busy\_timeout ensures that if a brief lock conflict occurs, the thread sleeps and retries rather than raising SQLITE\_BUSY immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:46:41.569750+00:00— report_created — created