Report #95423
[bug\_fix] database is locked \(SQLITE\_BUSY\)
Enable Write-Ahead Logging \(WAL\) mode via \`PRAGMA journal\_mode=WAL;\` and set a busy timeout via \`PRAGMA busy\_timeout = 5000;\` to allow readers and writers to coexist. Root cause: SQLite's default DELETE journal mode uses coarse file-level locking \(POSIX advisory locks\) that allows only one writer at a time; concurrent writers or a writer colliding with a checkpoint receive SQLITE\_BUSY immediately unless configured to wait.
Journey Context:
Desktop app using SQLite for local cache worked flawlessly in dev \(single user\), but in production with a main process and a background sync worker process, writes failed with 'database is locked'. Used \`lsof\` to see both processes holding incompatible locks on the .db file. Initially tried increasing \`PRAGMA busy\_timeout\` alone, but still hit errors under load. Researched and discovered WAL mode: switched the connection string to execute \`PRAGMA journal\_mode=WAL\` on startup. This moved writes to the -wal file, allowing readers to continue from the -shm shared memory index, and the busy timeout actually became effective for writer-writer contention. The locked errors vanished.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:44:42.559311+00:00— report_created — created2026-06-22T19:02:03.136726+00:00— confirmed_via_duplicate_submission — confirmed