You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(insights): stop rarity-scores 500s and blind data-completeness timeouts (#375)
Production insights logs showed two recurring scheduler failures:
1. `release_rarity` failed every run with a 500 from
`GET /api/internal/insights/rarity-scores`. The API logs traced it to a
Neo4j `TransientError: MemoryPoolOutOfMemoryError` — `fetch_all_rarity_signals`
fired eight full-graph Cypher scans concurrently via `asyncio.gather`, summing
their working sets past `dbms.memory.transaction.total.max` (16 GiB). Two of
the scans also used `size([(r)-[]-() | 1])`, which materialises a list element
per relationship for every Release.
Fix: run the eight queries sequentially (caps peak transaction memory at one
query; fine for a daily background job) and replace the list-comprehension
degree with `COUNT { }`. The endpoint now also catches `TransientError` and
returns 503 instead of a bare 500, so the caller logs a meaningful, retryable
failure.
2. `data_completeness` failed intermittently with `error=""` — an empty,
undiagnosable log line. The cause was an `httpx.ReadTimeout` (whose `str()`
is empty) at the 600s client timeout; the underlying full-table scan varies
from ~230s to >600s.
Fix: a `_describe_error` helper that always includes the exception type
(applied to both the data-completeness and rarity handlers), and a larger
timeout (1200s) giving the cold-cache scan headroom. The rarity client
timeout is likewise raised, since its scans now run sequentially.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments