SQLite 'database is locked' when manual fetch overlaps the scheduler #97
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?
Running a manual "Fetch All Active Streams" while the scheduler's fetch job is active produces
sqlite3.OperationalError: database is lockedin the scheduler (_fetch_stream_job). The scheduler flushes saved posts (acquiring SQLite's single write lock) and then holds it through the slow inline AI classification (image download + vision, tens of seconds) until commit. Concurrent manual fetches write to the same SQLite file, and the engine config has no busy timeout (connect_argsonly setscheck_same_thread=False), so the loser errors immediately instead of waiting.Findings: SQLite's busy timeout is effectively zero here (the engine's
connect_argssets onlycheck_same_thread=False), so a concurrent writer errors immediately. And the fetch flow holds the write lock across the slow inline classification (image download + vision, tens of seconds).Plan:
database.py: add a SQLiteconnectevent listener runningPRAGMA busy_timeout = 30000on each new connection, so a writer waits up to 30s instead of erroring.scheduler._fetch_stream_job,fetch_hashtag_stream, liveview_fetch_all_active_streams) todb.commit()the saved posts + deterministic auto-reject beforeclassify_posts, releasing the write lock during the slow AI calls, then a second commit for the classification + AI auto-reject.Branch:
feat/issue-97-sqlite-locking, PR intofeat/issue-80-collectwithRefs #97.