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
{{ message }}
Repository navigation
GET /v3/memories 504s at the 30s edge timeout: the first page walks every canonical-suppressed historical row #11798
GET /v3/memories has been returning 504 at exactly 30.00s in prod at ~100/hour since 2026-08-18T03:00Z (77 in hour 03, 111 in hour 04, 100 in hour 05), up ~10x from a ~10/hour baseline. Every one is a first page — offset=0, limit=8/100/5000, no cursor — and they are overwhelmingly the Windows desktop app (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36), ~10 distinct client IPs per hour. They continue on the current revision backend-523d194-32102746612-1 (deployed 05:34:34Z), so this is not the stale image and not the #11791 503 outage, which cleared at 03:18:40Z.
Successful requests on the same endpoint are also slow: p50 1.07s, p95 11.79s in the 05:00Z hour.
Root cause
MemoryService.read_page merges a canonical and a historical keyset stream. Both walk past every row they must not emit before they can fill the page — _HistoricalRawStream.peek() is a while True that refills 50 rows per Firestore round trip and skips each canonical_identity / canonical_state suppressed row, with no bound. For an account whose historical rows are all suppressed by canonical (the normal end state of the canonical migration), a limit=8 first page scans the entire historical collection.
Measured by driving the real FastAPI route with a fully suppressed account:
suppressed rows
sequential Firestore round trips
8,000
161
~30,000
~600
At ordinary Firestore latency ~600 sequential queries is past 30s, which is exactly the observed 30.005s.
Why it started at 03:00Z
The historical keyset scans order by (updated_at DESC, __name__). Until the memories composite index went READY at 2026-08-17T21:36Z they returned FAILED_PRECONDITION, read_page raised Historical memory unavailable, and the route fell back to the offset read() — which does not walk suppressed rows. The 504s are the walk finally running for real, and they jumped the moment #11791's 503s cleared.
Fix in progress: bound the skipped work per request and reuse the existing first-page offset-read fallback.
Activity