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
[P1] Prod GET action-items/memories/knowledge-graph hit HTTP_GET_TIMEOUT (30s) → 504; unbounded Firestore reads #10746
Production Cloud Run backend returns HTTP 504 with latency pinned at ~30.000s on heavy-tail list/read routes while /v1/health stays green:
GET /v1/action-items
GET /v3/memories (canonical first page)
GET /v1/knowledge-graph
(secondary) GET /v2/apps/search
Evidence cutoff 2026-07-27T22:45Z (read-only): overall 5xx ~0.02% last 1h, but concentrated; last 6h ~958×504; peak hour ~269×504. Same class existed pre-7fd2aac at lower rate; several× worse after that deploy window (not proven as a single-line handler regression — image primarily #10661 desktop).
Full report: omi-knowledge projects/prod-deploy-readiness/evidence/2026-07-27-prod-backend-504-deep-dive.md
Confirmed mechanism
App TimeoutMiddleware + env HTTP_GET_TIMEOUT=30 returns bare 504 on asyncio.TimeoutError (backend/utils/other/timeout.py).
get_action_items: full-collection query.stream(), filter/sort in process, then offset/limit — FirestoreReadMode.UNBOUNDED (backend/database/action_items.py).
Knowledge graph: unbounded stream of nodes + edges (backend/database/knowledge_graph.py).
Canonical /v3/memories first page forces clamped_limit = 5000 (backend/routers/memories.py).
GKE listen image skew is not causal for these Cloud Run GET routes.
Non-goals
Raising GET timeout alone (masks cost; worsens thread hold).
Rollback of 7fd2aac solely for this (prior revision still 504’d).
POST /v1/conversations/from-segments fast 500s (separate LLM BadRequest class).
Deploy/listen release-vector work (separate ops cut).
Acceptance
Default list paths use server-side bounded reads (hard max docs and/or time) while preserving required product ordering (e.g. active-first action items) via index/denorm/cursor — not full-collection stream+sort.
Load-style unit/integration fixtures with N ∈ {1k, 5k, 20k} complete p95 ≪ 30s for the three routes (or document API pagination contract + client follow-up if shape must change).
Canonical memories first-page must not force 5000 without a safe path (cursor pagination and/or lower hard cap with explicit client contract).
Focused regression tests + backend/test.sh selection / preflight as applicable.
Do not “fix” by only increasing HTTP_GET_TIMEOUT.
Out of scope for this issue
Prod GKE desktop-backend orphan retirement (Cloud Run is authority; chart already retired — live cleanup is separate authorized ops per docs/runbooks/desktop-backend-cloud-run-ownership.md).
Activity
fix(backend): bound Firestore list reads to stop 30s GET 504s (#10750)
fix(backend): bound Firestore list reads to stop 30s GET 504s (BasedH…