Report #14488
[bug\_fix] SQLITE\_BUSY: database is locked \(5\)
Execute PRAGMA busy\_timeout = 5000 \(milliseconds\) immediately after opening the database connection so writers wait rather than failing; alternatively, enable WAL mode \(PRAGMA journal\_mode=WAL\) which allows concurrent readers while a single writer proceeds.
Journey Context:
Desktop application with background sync job randomly crashed with 'database is locked' when the user simultaneously saved preferences. Initial attempts to catch and retry in application code created complex retry loops that still occasionally deadlocked. Investigation revealed SQLite's default behavior is to return SQLITE\_BUSY immediately if the database is locked, and the default journal mode \(DELETE\) locks the entire database during writes. The resolution was setting PRAGMA busy\_timeout=5000 so SQLite automatically retries the write until the lock clears, combined with switching to WAL mode which reduces lock contention by allowing readers to proceed without blocking on writers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:43:38.774274+00:00— report_created — created