Repository navigation
feat(relay): alert on cell disconnect bursts and database pool herds - #26363
Conversation
Two alert policies that separate a load-balancer mass disconnect from a database stall, after the 2026-10-06 18:34Z asia-east2 drop: - Disconnect burst: over 120 code-1006 desktop control closes on one cell in a minute, counted from the cell's own close line. The LB's internal_error log entries carry the stream start as their timestamp (median 2.4 h before the drop), so an LB-log rate never shows the pulse. - Pool herd: a cell runtime sample with more than 50 requests queued for a PostgreSQL connection (interval maximum, bar in the filter). Also publishes orca_relay_host_hellos_shed for the refusal counter from #26362, and pins both filters to the relay's text in a contract test.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe change adds Terraform metrics and alerts for abnormal relay control closes and database pool queue pressure. It adds tests for the metric and alert configuration, registers the alert resources in the relay fixture family list, and includes the test in the root pretest suite. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to This change adds monitoring alerts for relay disconnect bursts and database pool herds. It does not alter application behavior. The thresholds may need tuning after real data arrives, but no merge-blocking risk is evident. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
asia-east2 cells reach 184-196 waiters outside any herd, so >50 would have fired in 84 episodes since 2026-10-03. >200 fires in 10, covering every known herd. Drops the false 'healthy peak is 2 waiters' baseline from the policy text.
A healthy cell peaks at 2 waiters (p99); the 50-196 readings are single-cell stalls that already time out. The 200 bar is unchanged.
ELI5
On-call gets two new alerts. One fires when a relay cell suddenly loses hundreds of desktop connections at once. The other fires when a cell has an unusually long line of requests waiting for a database connection. If both fire together, the network dropped the desktops and their reconnects jammed the cell, so the database is fine. If only the second fires, look at the database.
What Changed
Before: on 2026-10-06 at 18:34 UTC, Google's load balancer dropped 1,046 asia-east2 desktop connections at once. An ops-log entry recorded it as a "big DB stall", because nothing distinguished a mass disconnect from a database problem.
After: three additions to
relay-observability.tf.Orca Relay: cell desktop disconnect burst(notifies). Fires when one GCE cell sees more than 120 desktop control sockets end without a close frame (code 1006) within a minute. It is built on a new counter,orca_relay_cell_control_abnormal_closes, which counts the cell's own[orca-relay] control closed ... code=1006log line.Orca Relay: cell database pool herd(notifies). Fires when a cell's runtime sample shows more than 200 requests queued at once for a PostgreSQL connection. It is built onorca_relay_cell_pool_herd, which keeps only samples withdatabasePoolWaitersMax > 200.orca_relay_host_hellos_shed. A snapshot metric for the refusal counter that fix(relay): refuse host hellos fast when the database pool is timing them out; renewals jump the queue #26362 adds. It stays empty until cells run that image.Each policy's documentation names the first response, including where to look and what not to touch.
Why
Why not count the load balancer's
internal_errorlog entries (the original plan). The load balancer writes a WebSocket's log entry when the stream closes, but stamps it with the time the stream started, and log-based metrics count by that stamp. In the 18:34 raw data, only 42 of the 1,046internal_errorentries were stamped within 10 minutes of the drop. The median stamp was 2.4 hours earlier and the oldest 7 hours earlier. A per-minute rate on those entries would smear the pulse across hours and never fire, and any stream older than 24 hours isn't counted at all. The cell logs each close at the moment it happens, so its line gives a rate that lines up with the drop.Why 120 per cell per minute. In the 18:34 minute, the five asia-east2 cells logged 213-247 such closes each. The minutes around it ran 6-49 per cell. US cells logged 17 or fewer closes per minute, counting every close code. The trade-off: the smaller drops that day, at 01:33 and 20:40 UTC (about 60 per cell), stay under the bar. Those cost 152-2,728 failed queries, against 17,912 at 18:34, and #26362 is meant to absorb them.
Why 200 waiters. A healthy cell peaks at 2 waiters (p99 on 2026-10-07). Single-cell stalls of 50-196 waiters recur several times a day, mostly on the asia-east2 cells. Each lasts about 30 seconds and is already timing requests out: the 184-196 readings on 10-07 each came with 96-367 SQL failures. Those stalls are left to the SQL-failure alerts, and this bar pages on herds. Episodes since 2026-10-03, from the review's production sample, reproduced from the raw samples:
At > 200, six of the ten episodes are herds across several cells: 10-03 17:50, 10-05 06:26 and 18:22, 10-06 01:33 and 18:34, and 10-07 20:00. The other four are a single cell at 201-228. Two samples in a row at > 150 also gives 10 episodes, but it fires a minute late on the 10-05 06:26 herd and still pages on a single cell at 196 (10-07 07:39). It also needs a condition that can straddle a minute boundary, so the simpler bar is the better fit for the data.
Why the interval maximum, and why the threshold sits in the filter.
databasePoolWaitersMaxis the largest queue seen during each 30-second sample, so a herd that lasts under a minute still shows. An instantaneous sample can miss it.Linked Issue
Fixes # (no issue; follow-up to the 2026-10-06 18:34Z asia-east2 RCA)
Visual Proof
N/A. Monitoring configuration only; no UI.
Testing
terraform validate(init with-backend=false) is clean, andterraform fmt -checkpasses.New
dev/scripts/relay-reconnect-herd-alerts.test.mjspins both filters to text the relay actually writes: the close log line inhost-session-registry.tsand thedatabasePoolWaitersMaxfield. A rename on either side now fails CI instead of silencing the alert.Added the three new resource families to
dev/fixtures/terraform-root-partition/families.json.The cloud
pretestset passes (193 tests), and so does the dev-scripttestset (737). The pin test now checks the> 200bar.Not applied anywhere. The thresholds come from the 18:33-18:37 UTC cell logs and the RCA, not from a longer baseline, so the 120 bar may need tuning after a week of data.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
relay-observability.tfandcloud/package.jsonare in the relay evidence-code set (relay-evidence-code-provenance.mjs). Merging this invalidates any sealed or in-flight monitor dry-run, so merge between rolls, then run a fresh monitor.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)