Skip to content

fix(cloud): wake reconnect-surge ignores object retirement waves, still fires on real drops - #48497

Merged
Jinwoo-H merged 2 commits into
mainfrom
jinwoo/wake-alerts-retirement-waves
Nov 25, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
jinwoo/wake-alerts-retirement-waves

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

The wake alerts page "reconnect-surge" whenever lots of desktops reconnect at once. Cloudflare periodically moves its Durable Objects (mostly in Asia), which drops every socket in a region for a moment. Every desktop is back within seconds and nothing is lost, but the alert fired anyway. Now it fires only when desktops don't come straight back, or wakes fail.

What Changed

cloud/apps/connector-wake/src/alerts-rules.ts, rule reconnect-surge:

  • Before: fired when socket opens in a 15-minute window were at least 3x the previous window and at least RECONNECT_SURGE_MIN.
  • After: fires when either of these holds (both 3x the previous window and at least RECONNECT_SURGE_MIN):
    • late reconnects surge: reconnects whose desktop-reported gap (reconnect_gap) is between 30 s and 1 h. The 1 h cap keeps out hosts that were simply away; after a switch widening, returning hosts report gaps of hours.
    • drops surge, and they hurt: drops are closes other than 1000, 1001 (going away, now graceful), 1005 (the desktop's own close without a code, e.g. leaving wake on a switch narrowing) and 4409 (replaced). Hurting means the extra reconnects (over the previous window) are under half the extra drops, or at least 3 wakes failed. Comparing excess to excess matters because steady-state reconnects run 3-8x the drops, which would otherwise hide a regional loss.
    • replacement surge: sockets that replaced an open socket for their host (socket_open 'replaced'). This is the stuck-but-open shape: the desktop terminates after two missed keepalives (~50 s), redials within 1 s, and the new socket replaces the old one with 4409. That produces no drops and no late gaps. A retirement wave closes sockets 1006 before the redial, so it replaces none.
  • Four new SQL columns: reconnects, reconnects_late, drops, replaced. The message gives drops, reconnects, late reconnects (30 s - 1 h), replaced sockets and failed wakes.
  • An empty window never surges, even with RECONNECT_SURGE_MIN set to 0.

Why

On 2026-11-24, reconnect-surge fired at 15:40 and 21:30 UTC (10:30 AM and 4:22 PM ET). Both were Durable Object retirement waves:

  • 15:40 window: opens 869 vs 242, drops (mostly 1006) 445 vs 66;
  • 21:30 window: opens 679 vs 173, drops 279 vs 34;
  • in both, 97% of reconnects came back within 5 s and 30 s - 1 h reconnects stayed at 20 and 9 per window;
  • reconnects were 1.6-1.8x the drops, and there were 0 wake errors.

Replay. I replayed both rules over the whole day's production orca_connector_wake_production data, per minute, at every 5-minute run with the production thresholds (RECONNECT_SURGE_MIN 50). The old rule fired 4 times; the new one fired once, on what looks like a real replace storm:

Run (UTC) What it was Old New
08:10, 08:45 switch widenings 0 → 100 → 300‰ (first connects) fired quiet
15:40 retirement wave fired quiet
19:40 narrowing 500 → 300‰: about 600 1005 closes that never came back, by design quiet quiet (1005 is graceful)
21:30 retirement wave fired quiet
22:30 widening 300 → 500‰: returning hosts, gaps of hours quiet quiet (gaps over 1 h don't count)
17:50 replace storm: 453 vs 132 replacements, redials within 1.5 s, 1006 flat. It ran 17:40-19:25, and the connector breaker opened at 18:05 and 19:17 quiet fires

What still fires, taking today's wave windows as the base:

  • the same drops with under half reconnecting, i.e. the Worker or objects broken and desktops falling back to long-poll (at 15:40, fires at 189 extra reconnects for 379 extra drops, quiet at 190);
  • a regional loss: +200 drops with no extra reconnects, on any of today's baselines, including 19:40 where reconnects ran 8x the drops;
  • a stuck-but-open storm: +600 replacements with fast redials, and today's 17:50 window;
  • the same drops plus 3 failed wakes;
  • 50 or more reconnects 30 s - 1 h late (3x the previous window). This is a slow recovery; today's waves had 9-20.

Alternatives I considered:

  • Raise RECONNECT_SURGE_MIN or the 3x factor: today's waves were 3.5-6.7x, so this would also hide a real drop of that size.
  • Require no_socket above a floor alongside the surge: production's no_socket share is 10-50% for hours after every widening (desktops not yet offered a socket), so that floor is no signal.

Testing

  • test/alerts.test.ts, with today's production windows as fixtures:
    • quiet on both retirement waves;
    • still fires on those windows with reconnects cut to 50, and with 3 failed wakes;
    • the under-half boundary;
    • the late-reconnect surge and its RECONNECT_SURGE_MIN / 3x boundaries;
    • quiet on the 08:10 widening and the 19:40 narrowing;
    • the SQL's graceful codes and gap band.
    • a regional loss on three production baselines; a stuck-socket replace storm, synthetic and the 17:50 window; an empty window with RECONNECT_SURGE_MIN 0.
  • Mutation checks:
    • the old opens rule fails 5 tests; RECOVERED_SHARE set to 0 fails 2;
    • total reconnects instead of excess fails 2 (including the regional test);
    • no replace branch fails the storm test;
    • no empty-window guard fails its test.
  • Run locally: vitest run test/alerts.test.ts (29 passed) and tsc --noEmit in cloud/apps/connector-wake (clean). cloud/ is outside oxlint and the package has no lint script.

Performance

None, because this only adds four sumIf columns to the alerts Worker's one SQL query every 5 minutes. Nothing changes in the wake Worker or its objects.

Risk

Level: Low.

  • The alert is Slack only, with no pager.
  • The riskiest part: a real drop that most desktops reconnect from within 30 s is now quiet. By then wakes are delivered again, and wake-errors, the probes and cloudflare-errors are unchanged.
  • Production picks this up only after cloud/connector-wake-source-revision in stablyai/orca-cloud is bumped and the alerts Worker is redeployed, which needs the owner's OK. Plain revert.

Review

…ll fires on real drops

reconnect-surge fired on socket opens >= 3x the previous window. On 2026-11-24 it fired at 15:40
and 21:30 UTC on Cloudflare Durable Object retirement waves (mostly Asia): 1006 closes, every
desktop back within seconds, no wake errors.

It now fires when either:
- reconnects 30 s - 1 h after their drop are >= 3x the previous window and >= RECONNECT_SURGE_MIN;
- drops (closes other than 1000, 1001 going away, 1005 the desktop's own close, 4409 replaced) are
  >= 3x and >= RECONNECT_SURGE_MIN, and fewer than half of them reconnected or >= 3 wakes failed.

Replayed over the whole day's production data at every 5 min run, it is quiet on both waves, on
the rollout widenings (08:10, 22:23) and on the 19:26 narrowing (1005 closes).
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The reconnect-surge alert now uses late reconnects, non-graceful socket drops, and replacement sockets instead of socket-open counts. It requires prior-window counts and evaluates reconnect and wake-error conditions. Tests cover retirement waves, threshold boundaries, SQL metrics, host-set changes, regional losses, replacement sockets, and empty windows.

Merge Risk: Low · up to 7521a

The reconnect-surge alert now ignores retirement waves that reconnect quickly. A wave that straddles a window boundary can still produce one transient false alert, which then clears on the next evaluation. This is acceptable to merge with owner awareness.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description covers most template sections. It has a clear ELI5, a detailed What Changed section with before and after behavior, a thorough Why section with production replay evidence and rejected … Add a linked issue, using 'Fixes #', or explain why none exists. Add 'N/A' with a reason under Visual Proof, because this change is an alert rule and has no UI change. Complete the AI Disclosure section. Tick or address the Testing …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: the reconnect-surge alert now ignores Durable Object retirement waves and still fires on real drops. It matches the PR objectives and description. The title is 91 char…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the reconnect-surge alert now ignores Durable Object retirement waves and still fires on real drops. It matches the PR objectives and description. The title is 91 characters, which is long but acceptable for a conventional-commit style title.

Full details: Description check

Explanation

The description covers most template sections. It has a clear ELI5, a detailed What Changed section with before and after behavior, a thorough Why section with production replay evidence and rejected alternatives, a Testing section with specific test coverage and mutation checks, a Performance answer, and a Risk section with level and revert path. Gaps: the 'Linked Issue' section has no 'Fixes #' reference, and the template requires one. The 'Visual Proof' section is absent or not addressed, though this is a backend alert rule and the template allows N/A. The 'AI Disclosure' section is not filled in, and the 'Agent skill upstream boundary' checkbox is not addressed. The Testing checklist boxes are not ticked. The 'Review' section is empty. The description says 29 tests passed in one place and the objectives say 26 in another; the description itself says 29, so the count is consistent within the description.

Resolution

Add a linked issue, using 'Fixes #<number>', or explain why none exists. Add 'N/A' with a reason under Visual Proof, because this change is an alert rule and has no UI change. Complete the AI Disclosure section. Tick or address the Testing checklist items and the Agent skill upstream boundary item. Fill in or remove the empty Review section.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

…and stuck-socket storms

Review (round 1) found two outage shapes the rule missed:
- A regional loss nobody reconnects from was hidden by the fleet's steady reconnects (3-8x the
  drops). Reconnects are now judged in excess of the previous window, as drops are: fires when
  the extra reconnects are under half the extra drops.
- Sockets stuck open (desktop terminates after two missed keepalives, redials within 1 s, the new
  socket replaces the old 4409) produced no drops and no late gaps. New column `replaced`
  (socket_open 'replaced'); fires when it is >= 3x the previous window and >= RECONNECT_SURGE_MIN.
  A retirement wave closes sockets 1006 before the redial, so it replaces none.

Also: never fires on an empty window with RECONNECT_SURGE_MIN 0, and the message gives the late
band as 30 s - 1 h. Replayed over 2026-11-24 production: quiet on both retirement waves, the
widenings and the narrowing; fires once, at 17:50 UTC, on a replace storm (453 vs 132, redials
within 1.5 s, 1006 flat) that ran 17:40-19:25 alongside connector breaker openings.
@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Review round 1, addressed in 7521a30:

  1. Regional loss masked by steady reconnects: reconnects are now judged in excess of the previous window: fires when extra reconnects are under half the extra drops. +200 drops with no extra reconnects fires on the 15:40, 21:30 and 19:40 baselines. Today's retirement waves stay quiet: 610 and 313 extra reconnects for 379 and 245 extra drops.
  2. Stuck-but-open storm: a new replaced column (socket_open 'replaced'), surging at >= 3x and >= RECONNECT_SURGE_MIN. On the waves it stayed flat: 100 vs 108 and 56 vs 104. On the full-day replay it fires once, at 17:50 UTC (453 vs 132, redials within 1.5 s, 1006 flat). That looks like a real replace storm: it ran 17:40-19:25 while the connector breaker opened twice.
  3. Minor: surged now requires a non-zero count (RECONNECT_SURGE_MIN 0 no longer fires on an empty window), and the message says 30 s - 1 h.
    Full-day replay of the whole rule: quiet on both waves, the 08:10, 08:45 and 22:23 widenings and the 19:26 narrowing; fires only at 17:50. 29 tests pass, each fix covered by a test that fails without it.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments: 1

cloud/apps/connector-wake/src/alerts-rules.ts: 1

110-110: Minor · Functional Correctness · Poor tradeoff

Count reconnects that land after the window boundary before classifying drops as unrecovered.

The current window ends at the scheduled time minus LAG_MIN. A socket that closes just before that boundary counts as a drop in the current window. Its reconnect lands after the boundary and falls outside the window, so it is not counted. When a retirement wave straddles the boundary, unrecovered sees extra drops without their extra reconnects. For example, baseline drops=66 and reconnects=192 become drops=445 and reconnects=192 when 379 sockets close just before the boundary and reconnect two seconds after it. harmfulDrops then fires, although every socket recovered within seconds. The next evaluation can resolve the alert, so the impact is one transient false FIRING.

Apply a bounded follow-up interval, or align the drop and reconnect events to the same window, before classifying drops as unrecovered. Make the change in the shared window definition, because reconnects never reaches unrecovered when it falls outside the current window. Keep alerts for drops that remain unrecovered after that interval.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 94670525-4b9c-4120-a25f-b7480b7c99c0
Commits

Reviewing files that changed from the base of the PR and between 03e6511 and 7521a30.

Files selected for processing: 2

  • cloud/apps/connector-wake/src/alerts-rules.ts
  • cloud/apps/connector-wake/test/alerts.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@Jinwoo-H
Jinwoo-H merged commit 3d42d65 into main Nov 25, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant