Skip to content

Run the task service's SQLite database in WAL mode - #437

Merged
tildesrc merged 1 commit into
mainfrom
panopticon/sqlite-wal-mode
Oct 22, 2026
Merged

tildesrc merged 1 commit into
mainfrom
panopticon/sqlite-wal-mode

Conversation

@tildesrc

Copy link
Copy Markdown
Contributor

The on-disk task store left SQLite at its default rollback journal (journal_mode=delete), so a committing writer locked every reader out. With ~25 live agents writing (949 writes in 17 minutes), the service logged sqlite3.OperationalError: database is locked, 8 of 9 on reads (list_tasks_summary / _tasks_snapshot). Those came back as 500s on the dashboard's long-poll and stalled its refresh.

Plan: task artifact plan.md (panopticon://tasks/1edca4fb888d4ce0a19ec6685a4800a0/artifacts/plan.md).

Changes

  • store_sqlalchemy.py: a connect listener on file-backed SQLite engines sets journal_mode=WAL, synchronous=NORMAL and busy_timeout=30000 (_SQLITE_BUSY_TIMEOUT_MS). In-memory / StaticPool engines are untouched. WAL mode is saved in the database file, so Alembic (make migrate) uses it too.
  • migrate_db_to_home: when a DB is moved from a legacy location, any -wal / -shm files next to it are moved too. A DB in WAL mode can keep recent commits in those files.
  • Tests (tests/core/test_store.py): the on-disk store reports wal / NORMAL / the timeout; in-memory stays memory; a read succeeds while another connection holds BEGIN EXCLUSIVE. That last test fails with database is locked without this change. There's also a sidecar-move test in test_home_migration.py.
  • Docs: README explains the -wal/-shm files and how to back up the DB (stop the service, or sqlite3 … .backup); AGENTS.md module map notes WAL.

🤖 Generated with Claude Code

The on-disk store left SQLite at its default rollback journal, so a
committing writer locked every reader out. Under ~25 live agents the
dashboard's long-poll reads failed with `database is locked` (500s).

Set journal_mode=WAL, synchronous=NORMAL and a 30 s busy_timeout on every
new connection to a file-backed SQLite DB (in-memory engines untouched).
The legacy-location DB move now carries any -wal/-shm sidecars with it,
and the README notes the sidecars and how to back the DB up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tildesrc
tildesrc marked this pull request as ready for review October 22, 2026 22:52
@tildesrc
tildesrc merged commit 220d833 into main Oct 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant