Skip to content

fix(relay): drain a same-cap cell over 5 minutes, not 2 - #22584

Merged
Jinwoo-H merged 3 commits into
mainfrom
relay-drain-pace-300s
Sep 24, 2026
Merged

Jinwoo-H merged 3 commits into
mainfrom
relay-drain-pace-300s

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

What changed

The same-cap relay cell rollout now spreads a cell's drain over 5 minutes instead of 2. One environment value in the reusable job plus its comment. No application code changes.

Before and after, as the user sees it

Before: when a large relay cell (about 2,000 hosts) was rolled, every desktop connected to it re-dialed the director within 2 minutes. The director serialises those re-placements and could only clear about 8 per second, so for about 5 minutes any Orca host anywhere trying to connect or reconnect got "try again in 2 seconds" repeatedly. Existing sessions were unaffected. Measured on 2026-09-23 during the c27 roll: about 22,000 rejected assign calls, 3% success at the worst minute.

After: the same drain takes 5 minutes, about 6 to 9 re-dials per second for the remaining cells, near or under what the director clears. Expected result is a short tail of slower reconnects rather than a multi-minute fleet-wide brownout. This is a mitigation for planned rolls only; the director-side fix that also covers crashes and mass restarts is tracked separately.

Mechanism

The cell's drain endpoint already spreads its drain sends evenly across a caller-supplied window, capped at 5 minutes. The workflow asked for 2 minutes based on a comment that mistook the Cloud Run request-concurrency setting for the director's assign capacity. The wait step that follows the drain already allows 17 minutes, so it outlasts the longer window.

Alternatives considered

  • Widening the director's sticky lane: needs a database pool change that the director deploy script pins, so it is not a config-only change and risks recreating the lock contention behind the 09-16 outage.
  • Releasing the sticky slot before the expensive re-placement, and jittering the retry hint: the durable fix, about 3 days, planned as a follow-up.
  • Rate-based pacing (hosts divided by a target rate): only takes effect on a cell's roll after next because the drain runs on the cell's current image.

Testing

Workflow-only change. Verified the cell accepts a 300000 ms window (inclusive maximum), the drain script's validation allows it, and the transition wait exceeds it. Will be exercised by the next same-cap roll (c30 first, the smallest remaining cell).

The 2026-09-23 c27 roll drained 2,145 hosts over the 2-minute window,
about 18 re-dials/s, while the director re-places roughly 8/s through
its single-slot sticky lane. The overflow queued behind slow
re-placements and timed out, so /v1/assign returned 503 fleet-wide for
about 5 minutes. 5 minutes is the cell's maximum pace window and keeps
the remaining 2,650-host cells near lane capacity. The transition wait
already outlasts a 5-minute window (17 min).

Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The production relay rollout workflow retains DRAIN_PACE_WINDOW_MS at 300000 milliseconds and revises its comment to describe the expected short tail and transition wait. The drain-wait timeout increases from 17 to 20 minutes. The pacing test now checks the five-minute window and the 20-minute timeout.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 2129e

The rollout timing is configured as intended, but its test could miss a future timeout regression. This is a bounded test gap rather than a current rollout failure.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, user impact, mechanism, alternatives, and testing. However, it omits required template content, including the Linked Issue with a Fixes # reference, the Visual P… Add the missing required template sections. Include the issue reference under Linked Issue, write N/A with a reason under Visual Proof if no visual or interaction change exists, complete the Testing checkboxes, and address the Review, Age…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely states the main change: increasing the same-cap cell drain window from 2 minutes to 5 minutes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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: Description check

Explanation

The description explains the change, user impact, mechanism, alternatives, and testing. However, it omits required template content, including the Linked Issue with a Fixes # reference, the Visual Proof section with N/A and a reason, and the required checklist and review sections.

Resolution

Add the missing required template sections. Include the issue reference under Linked Issue, write N/A with a reason under Visual Proof if no visual or interaction change exists, complete the Testing checkboxes, and address the Review, Agent skill upstream boundary, Notes, and Checklist sections.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

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

Comment @coderabbitai help to get the list of available commands.

@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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 81a07310-6587-4c3c-9fe0-e70b4a5690d0

📥 Commits

Reviewing files that changed from the base of the PR and between 4064653 and 0f8bba3.

📒 Files selected for processing (1)
  • .github/workflows/cloud-deploy-relay-production-same-cap-job.yml

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@pullfrog pullfrog 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.

Important

Changing DRAIN_PACE_WINDOW_MS leaves the census test that pins it at '120000', so cloud's pnpm test fails. One-line test update needed before merge.

Reviewed changes

  • Drain pace widened to 5 minutes — the reusable same-cap job's DRAIN_PACE_WINDOW_MS goes '120000' → '300000', and the comment above it is rewritten to explain the director's ~8 hosts/s sticky-lane ceiling and the 2026-09-23 assign brownout.

The mechanism is sound: 300000 sits exactly on the cell's inclusive cap (DRAIN_PACE_WINDOW_MAX_MS = 5*60*1000, cloud/apps/relay/src/app.ts:63,502) and the script validator's MAX_PACE_WINDOW_MS (cloud/dev/scripts/prepare-relay-production-capacity-canary.mjs:39,76), and the following transition wait --timeout-ms 1020000 still outlasts the longer window. The one blocker is the un-updated pin, reported inline.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
The transition wait after a drain was set to the 15-minute migration
lease plus the pace window. Widening the window to 5 minutes without
moving the wait left 12 minutes for a migration that can hold for 15,
so a late-window migration would time the wave out into rollback.

Claude-Session: ced32ebb-7155-4413-adad-1eccd14c2010
@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Review round 1 addressed: the same-cap contract test now pins the 5-minute window; the post-drain transition wait moves from 17 to 20 minutes so it stays at the 15-minute migration lease plus the window; the header comment no longer claims a 2,700-host cell sits within capacity.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes (since the prior pullfrog review at 0f8bba3)

  • Census pin updated — cloud/dev/scripts/relay-same-cap-script-census.test.mjs now pins DRAIN_PACE_WINDOW_MS: '300000' instead of '120000', clearing the failing assertion the prior review blocked on. Verified locally: node --test cloud/dev/scripts/relay-same-cap-script-census.test.mjs passes 25/25.
  • Transition wait raised to 20 minutes — --timeout-ms goes 1020000 → 1200000, i.e. the 15-min migration lease plus the 5-min window. The paced drain returns immediately and spreads sends over the window, so the verify budget does need to cover both; the census assertion follows the new literal.
  • Env comment rewritten — the drain comment now states the 15-min lease plus window arithmetic instead of the old "well under the director's cap" claim.

The delta is workflow/test-only and mechanically consistent: the window sits exactly on the cell's inclusive cap, and the wait literal matches the lease-plus-window sum.

ℹ️ Nitpicks

  • The PR body's "Mechanism" section still says the wait "already allows 17 minutes"; the new commit raises it to 20 minutes, so that sentence is now stale.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 8d4c974a-827e-4baf-b2be-e056e65cc4cd

📥 Commits

Reviewing files that changed from the base of the PR and between 0f8bba3 and 2129e39.

📒 Files selected for processing (2)
  • .github/workflows/cloud-deploy-relay-production-same-cap-job.yml
  • cloud/dev/scripts/relay-same-cap-script-census.test.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/cloud-deploy-relay-production-same-cap-job.yml

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

assert.match(workflow, /DRAIN_PACE_WINDOW_MS: '300000'/)
// The transition wait has to outlast the pacing window on top of the leases it waits on.
assert.match(workflow, /--activity restart-safe[\s\S]*?--timeout-ms 1020000/)
assert.match(workflow, /--activity restart-safe[\s\S]*?--timeout-ms 1200000/)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -C 12 -- '--activity restart-safe|--timeout-ms' .github/workflows/cloud-deploy-relay-production-same-cap-job.yml

Repository: stablyai/orca

Length of output: 3391


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '300,325p' cloud/dev/scripts/relay-same-cap-script-census.test.mjs
sed -n '568,586p' .github/workflows/cloud-deploy-relay-production-same-cap-job.yml
sed -n '738,752p' .github/workflows/cloud-deploy-relay-production-same-cap-job.yml

Repository: stablyai/orca

Length of output: 3685


Bind the timeout assertion to the restart-safe command.

The current regex can cross command boundaries. Match only continued option lines for this command so a later timeout cannot satisfy the assertion.

Suggested fix
-    assert.match(workflow, /--activity restart-safe[\s\S]*?--timeout-ms 1200000/)
+    assert.match(workflow, /--activity restart-safe[^\n]*\\\n(?:[ \t]+--[^\n]*\\\n)*[ \t]+--timeout-ms 1200000/)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
assert.match(workflow, /--activity restart-safe[\s\S]*?--timeout-ms 1200000/)
assert.match(workflow, /--activity restart-safe[^\n]*\\\n(?:[ \t]+--[^\n]*\\\n)*[ \t]+--timeout-ms 1200000/)

@Jinwoo-H
Jinwoo-H merged commit 128e97f into main Sep 24, 2026
25 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