SQLite accessed via a fresh connection per call, no WAL mode — risk of 'database is locked' under concurrent access #4
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
paul_loth/krautspaceTV#4
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
backend/db.pyopens a brand-newaiosqlite.connect(DB_PATH)for every single function call (list_slides,get_slide,add_slide, ...), with SQLite's default rollback-journal mode (not WAL). No connection is shared/pooled.Given the multi-process architecture (4 independent
rotation_loop()s, see separate issue, each polling the DB every rotation cycle) plus concurrent admin writes, SQLite's default journal mode serializes writers and can raisedatabase is lockedunder contention — especially noticeable if the interval is short or many admin edits/view-now clicks happen close together.Suggested fix
PRAGMA journal_mode=WAL;) once at startup, which allows concurrent readers alongside a writer and greatly reduces lock contention.aiosqliteconnection (or a small connection pool) per process instead of opening/closing one per call.Fixed in
8835778: enabled PRAGMA journal_mode=WAL in init_db(), which allows concurrent readers alongside a writer and avoids 'database is locked' errors under the multi-process access pattern.