Skip to content

[P1] Prod GET action-items/memories/knowledge-graph hit HTTP_GET_TIMEOUT (30s) → 504; unbounded Firestore reads #10746

Closed

Description

@Git-on-my-level

Problem

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

  1. 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.
  2. 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).
  3. Canonical memories first-page must not force 5000 without a safe path (cursor pagination and/or lower hard cap with explicit client contract).
  4. Focused regression tests + backend/test.sh selection / preflight as applicable.
  5. 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).

References

  • Hub: projects/prod-deploy-readiness/
  • Code anchors above

Activity

  1. added
    bug
    backend
    p1
    on Jul 27, 2026
  2. added a commit that references this issue on Jul 28, 2026
    aad6f23
  3. added a commit that references this issue on Jul 29, 2026
    3839430
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendbugp1reliability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions