Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

perf: keep UltraWiki status off the writer connection

Ruben Lütkefd002c563754
diff --git a/jarvis/ultrawiki/store.py b/jarvis/ultrawiki/store.py
index d010ddddaa..8c03363780 100644
--- a/jarvis/ultrawiki/store.py
+++ b/jarvis/ultrawiki/store.py
@@ -900,7 +900,10 @@ class UltraStore(IdentityMixin, EventMixin):
async def list_sources(self) -> list[dict[str, Any]]:
"""All sources with per-source pipeline counts and sync state."""
- conn = await self._ensure_open()
+ # Status polls must not queue behind a large import transaction on the
+ # writer connection. WAL readers see the latest committed snapshot and
+ # keep the Overview responsive while a source is being reconciled.
+ conn = await self._read_conn()
rows = await self._fetchall(conn, "SELECT * FROM uw_sources ORDER BY id")
count_rows = await self._fetchall(
conn,
@@ -1504,7 +1507,7 @@ class UltraStore(IdentityMixin, EventMixin):
async def counts(self) -> PipelineCounts:
"""Per-stage backlog counts over live (non-tombstoned) items."""
- conn = await self._ensure_open()
+ conn = await self._read_conn()
rows = await self._fetchall(
conn,
"SELECT state, COUNT(*) AS n FROM uw_items"
diff --git a/tests/unit/ultrawiki/test_store.py b/tests/unit/ultrawiki/test_store.py
index b48ebe31b3..388fd219e4 100644
--- a/tests/unit/ultrawiki/test_store.py
+++ b/tests/unit/ultrawiki/test_store.py
@@ -855,6 +855,19 @@ async def test_search_reads_run_on_the_pooled_readers(store):
assert store._read_conns, "expected a populated read-only pool"
+async def test_status_reads_run_on_the_pooled_readers(store):
+ """Overview polling stays independent from long writer transactions."""
+ await add_source(store)
+ await seed_indexed(store, [make_item(1, body="alpha content")])
+
+ counts = await store.counts()
+ sources = await store.list_sources()
+
+ assert counts.total == 1
+ assert sources[0]["counts"].total == 1
+ assert store._read_conns, "expected status queries to populate the reader pool"
+
+
async def test_reader_pool_failure_degrades_to_the_writer(store, monkeypatch):
"""No pool, no problem: correctness never depends on read-only
connections being available (in-memory paths, exotic filesystems)."""