Report #76483
[bug\_fix] database is locked \(SQLITE\_BUSY\)
A writer cannot acquire the necessary locks because another connection holds a read or write lock on the database. In DELETE journal mode \(default\), a writer needs an exclusive lock on the entire database file. In WAL mode, a writer is blocked if a read transaction is holding back the checkpoint. The fix is to set PRAGMA busy\_timeout=5000 \(milliseconds\) to allow SQLite to retry instead of returning immediately. For high concurrency, switch to WAL mode \(PRAGMA journal\_mode=WAL\) which allows concurrent readers and a single writer. Ensure long-running read transactions are avoided as they block WAL checkpoints.
Journey Context:
The desktop application sporadically failed to save data with database is locked. The developer initially thought the file was corrupted. They discovered the default busy timeout was 0, meaning any lock conflict immediately aborted the operation. They found another background thread was holding a long-running read transaction on the same connection pool. They tried increasing the busy timeout to 10 seconds, but the error persisted under heavy load. They then examined the journal mode and found it was DELETE. They switched to WAL mode, which allowed the writer to proceed even while readers were active, and the locking errors disappeared completely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:57:58.359701+00:00— report_created — created