Report #90483
[bug\_fix] database is locked \(SQLITE\_BUSY\)
Execute \`PRAGMA journal\_mode=WAL;\` immediately after opening the database to enable Write-Ahead Logging. WAL mode allows concurrent reads during writes and uses a shared-memory wal-index for coordination instead of exclusive database file locks, eliminating the SQLITE\_BUSY error for read-heavy workloads and allowing readers to not block writers.
Journey Context:
A developer builds a Python Flask app using SQLite. In development with a single process, it works perfectly. Deployed to production with Gunicorn using 4 workers, users intermittently see "database is locked" errors. The developer adds \`PRAGMA busy\_timeout = 5000\` which reduces errors but doesn't eliminate them under high load. Checking SQLite docs, the developer learns the default DELETE journal mode only allows one writer at a time and locks the entire file. By switching to WAL mode via \`PRAGMA journal\_mode=WAL;\`, readers no longer block writers, and writers don't block readers. The app now handles concurrent requests without SQLITE\_BUSY because WAL uses a separate file for changes and a shared memory index for coordination, allowing true concurrent read-write access.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:28:19.553976+00:00— report_created — created