Skip to content

fix(relay): keep pool pressure a per-cell rehome exclusion, not a fleet stop - #21126

Merged
Jinwoo-H merged 1 commit into
mainfrom
relay-rehome-unblock
Sep 17, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
relay-rehome-unblock

Conversation

@Jinwoo-H

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

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

ELI5

Relay can move a paired host to a relay server in a closer region ("regional rehoming"). Before it moves anyone, a worker on the director checks that the fleet is healthy. One of those checks looked at the single worst database-pool reading across every relay cell. Three cells in Asia are permanently over that bar because their round trip to the US database is long, so the check failed on every poll and rehoming could never start. Worse, the same check runs again at commit time and turns the whole feature off if it trips there. This PR makes pool pressure a reason to skip one cell, not a reason to stop the fleet.

What Changed

Before: the fleet-wide safety gate in regionalRehomeSafetyFailure returned database_pool_pressure whenever the fleet-wide maximum of pool waiters exceeded 16 or peak pool wait exceeded 250 ms. With the three asia-east2 cells at 94-156 waiters and ~2000 ms, the candidate selector returned zero candidates on every poll, silently. Had a candidate ever reached the commit path while the bar flapped, pauseRegionalRehomeForSafety would have durably disabled the switch.

After: the fleet gate no longer checks pool pressure. Pool pressure remains a per-cell exclusion in regionalRehomeCellSafetyIsClean, which already drops a cell over either bar as both source and target, on selection and again on the commit path. A saturated cell simply sits out. The other fleet bars (stale monitoring, SQL-failure storms, control-recovery failures, reconnect storms) are unchanged.

Nothing cells publish, no stored row, and no exported constant changes. Director-only behaviour; no cell roll needed.

Why

Measured in production on 2026-09-16:

  • The asia cells' server-side statement execution is 0.2 ms. The waiters measure a client pool too narrow for a 176 ms round trip, not database distress. The bar cannot tell those apart.
  • All 16 us-central general cells also breach the bar in short bursts. With the two-window peek the heartbeat publishes, a fleet with asia removed would still trip the gate on about a third of polls. So raising the constants until asia passes would not have fixed it, and a flapping fleet bar plus the durable-disable on the commit path means the switch would turn itself off within minutes of enabling.
  • The 2026-09-12 production enable at cohort 100 worked and moved one host; c27 was at 2-6 waiters then. Saturation started on 09-13 and became continuous on 09-14.

Alternatives considered: re-baselining the two constants (arbitrary, and still flaps on us-central); making the fleet bar "N cells dirty" instead of "any cell dirty" (more machinery for the same outcome, since the per-cell exclusion already covers the cells that matter); widening the asia pool first (a real fix for asia's renewal timeouts, but it needs a validator change plus a cell roll and does not address the us-central flapping). The asia pool bump proceeds separately.

Linked Issue

No tracked issue. This is the operational unblock for turning on the 10% region-correction cohort that is already configured on the director.

Visual Proof

N/A. Server-side safety-gate logic with no UI.

Testing

  • cd cloud/apps/relay && pnpm test: 62 files, 625 tests passed (sqlite).
  • regional-rehome-postgres.test.ts, regional-rehome-store.test.ts, regional-rehome-safety.test.ts against a fresh postgres:16-alpine container: 73 tests passed.
  • cd cloud/apps/relay && pnpm typecheck: clean.
  • Mutation check: reinstating the fleet pool check makes exactly the three new/inverted tests fail.

Tests: still fails closed on each pool pressure bound is replaced by an assertion that asia-scale pool pressure passes the fleet gate while every other bar still fails with its existing reason. latches off on sustained pool pressure is inverted into defers on target pool pressure without disabling, and claims once it clears. A new store test puts a bystander cell at asia-scale pressure and shows selection still returns candidates.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Remote wire compatibility: no RPC, stream, or published-content change. Cells on any image keep publishing the same safety row; only the director's reading of it changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…et stop

The fleet safety gate returned database_pool_pressure whenever the
Math.max of database_pool_waiters_max or database_pool_wait_ms_max
across every general cell crossed 16 waiters or 250ms. Measured
2026-09-16, the asia-east2 cells breach continuously at 94-156 waiters
and ~2000ms while their server-side execution is 0.2ms, which is a
client pool too narrow for a 176ms round trip rather than database
distress, and the us-central1 cells breach in bursts on about a third of
polls. Worse, the bar flaps: the pre-check passes, the commit re-check
reads fresh rows seconds later and trips, and that path durably disables
the control instead of merely deferring.

Drop the pool check from the fleet gate. Pool pressure stays a per-cell
exclusion in regionalRehomeCellSafetyIsClean, which already drops a
breaching cell as both source and target on selection and again on the
commit path. The fleet bars that remain (stale monitoring, sql failure
storms, control-recovery failures, reconnect storms) all signal
database-wide distress. Nothing cells publish, no stored row and no
exported constant changes.
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: e0e7f133-d681-4886-9763-6aee790f6b8a

📥 Commits

Reviewing files that changed from the base of the PR and between 4b87675 and c474c2b.

📒 Files selected for processing (3)
  • cloud/apps/relay/src/regional-rehome-safety.test.ts
  • cloud/apps/relay/src/regional-rehome-safety.ts
  • cloud/apps/relay/src/regional-rehome-store.test.ts

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


📝 Walkthrough

Walkthrough

The regional rehome safety evaluator no longer fails the fleet on pool-pressure thresholds. Pool pressure remains part of cell-level snapshot data. Tests now verify that other safety bars still fail closed, target-cell pressure defers a candidate without disabling durable control, and unrelated bystander-cell pressure does not prevent candidate selection.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to c474c

Pool pressure now defers only affected cells while unaffected regional rehomes can continue. No actionable current-head issue remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, behavior change, rationale, testing, and compatibility impact. However, it does not provide the required linked issue and explicitly states that no tracked issue … Add the tracked issue reference in the Linked Issue section using the required Fixes #<issue-number> format, or obtain an approved exception to the repository requirement for linked issues.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: treating pool pressure as a per-cell rehome exclusion instead of a fleet-wide stop.
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 problem, behavior change, rationale, testing, and compatibility impact. However, it does not provide the required linked issue and explicitly states that no tracked issue exists.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@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

This removes the fleet-wide pool-pressure check from regionalRehomeSafetyFailure, leaving pool pressure as a per-cell exclusion only. It is correct and well covered.

  • regionalRehomeSafetyFailure no longer gates on pool pressure — the check at regional-rehome-safety.ts:50 is gone; pool_waiters_max / pool_wait_ms_max are no longer read on the combined snapshot. The other four fleet bars (stale monitoring, sql failures, control-recovery failures, reconnect storms) are unchanged.
  • Per-cell exclusion is unchanged — regionalRehomeCellSafetyIsClean still drops a cell over either pool bar, and both candidate selection (selectIdleRegionalRehomes, applied to source and target) and the commit path already use it. A saturated cell sits out; all-cells-saturated yields no candidates.
  • Tests inverted/added — the fleet-pool assertion is replaced with one showing asia-scale pool pressure passes while every other bar still fails at that pressure; the durable-latch test now asserts a target pool breach defers without disabling and claims once cleared; a bystander at asia-scale pressure no longer empties the candidate page.

I verified that reinstating the removed fleet pool check makes exactly the three new/inverted tests fail, confirming they pin the intended behavior. The full cloud/apps/relay sqlite suite passes (62 files, 625 tests), and database_pool_pressure has no remaining references or stale docs.

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

@Jinwoo-H
Jinwoo-H merged commit 77cd61d into main Sep 17, 2026
26 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…et stop (stablyai#21126)

The fleet safety gate returned database_pool_pressure whenever the
Math.max of database_pool_waiters_max or database_pool_wait_ms_max
across every general cell crossed 16 waiters or 250ms. Measured
2026-09-16, the asia-east2 cells breach continuously at 94-156 waiters
and ~2000ms while their server-side execution is 0.2ms, which is a
client pool too narrow for a 176ms round trip rather than database
distress, and the us-central1 cells breach in bursts on about a third of
polls. Worse, the bar flaps: the pre-check passes, the commit re-check
reads fresh rows seconds later and trips, and that path durably disables
the control instead of merely deferring.

Drop the pool check from the fleet gate. Pool pressure stays a per-cell
exclusion in regionalRehomeCellSafetyIsClean, which already drops a
breaching cell as both source and target on selection and again on the
commit path. The fleet bars that remain (stale monitoring, sql failure
storms, control-recovery failures, reconnect storms) all signal
database-wide distress. Nothing cells publish, no stored row and no
exported constant changes.
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