Skip to content

perf(runtime): investigate synchronized workspace latency step after 20:00Z #672

Description

@tiankaima

Incident summary

Two independent bearer-authenticated workspace routes developed the same persistent latency step at approximately 2026-07-28 20:00Z, 11.5 hours after v1.77.21 reached 100% production. All responses remained 200 and Workers reported no runtime errors, exceeded-resource events, or memory events.

This timing does not support labeling the incident a #670 deployment regression or a Prisma-client regression.

Production evidence

Equal six-hour windows, exactly 72 calls per endpoint in each window:

Route Metric 14:00–20:00Z 20:00–02:00Z
/api/workspace/homeworks observed I/O avg / p50 / p95 112 / 104 / 160 ms 3101 / 3245 / 3581 ms
sampled CPU avg 141 ms 297 ms (+110%)
Workers wall avg 249 ms 3097 ms (+1144%)
/api/workspace/subscriptions/current observed I/O avg / p50 / p95 88 / 82 / 125 ms 2271 / 2488 / 2798 ms
sampled CPU avg 92 ms 286 ms (+210%)
Workers wall avg 189 ms 2298 ms (+1115%)

Both routes remained slow through the latest complete window ending 2026-07-29 06:15Z. The section-detail CPU distribution decreased across the same boundary, so catalog concurrency is not a sufficient explanation.

The scheduled Static Sync ran 19:21:25–19:24:54Z. It completed successfully and did not overlap the 20:00Z boundary; the temporal proximity is worth testing at the next run but is not causal evidence.

Likely layers to distinguish

  • Hyperdrive connection acquisition / placement change;
  • database execution/lock/cache state or account-specific row shape;
  • request-scoped pg pool connection churn;
  • auth/token lookup versus application data queries;
  • scheduled production maintenance effects.

Related: #45 in Life-USTC/Bot will consolidate periodic reads and reduce aggregate load, but that change must not be treated as resolving this per-call latency incident. #603 owns the production Hyperdrive role/cache architecture; #530 owns Worker route CPU attribution.

Acceptance criteria

  • Capture a trace or equivalent timing split for auth, pool/connect, and each database read without logging credentials or row data.
  • Compare at least one slow production-equivalent request with a fast request using the same route/account shape.
  • Record Hyperdrive placement/config/version and database health/locks around a subsequent scheduled sync boundary.
  • Determine whether the latency follows route, user/account data volume, colo/placement, connection creation, or database query execution.
  • Add only the instrumentation needed to close the attribution gap; successful high-frequency logs must remain sampled.
  • Implement a demonstrated fix with a focused load/shape regression test.
  • Verify both routes over a complete post-deploy window with p50/p95/p99 and error/resource-limit rates.
  • Keep the production role/cache safety work in security(db): replace production Hyperdrive postgres origin with cache-disabled RLS runtime role #603; do not enable caching for auth, permission, or user-fresh reads as a latency workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: dataPrisma, migrations, seed/import pipelines, transactions, and persistence invariantsarea: infrastructureProduction runtime, Cloudflare, storage, containers, deployment, and releasesarea: observabilityMetrics, health checks, telemetry, tracing, operational logging, and audit deliverybugSomething isn't working

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions