Repository navigation
fix(relay): keep pool pressure a per-cell rehome exclusion, not a fleet stop - #21126
Conversation
…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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe 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 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)
✅ Passed checks (3 passed)
Full details: Description checkExplanation 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.
✨ Finishing Touches 💡 1📝 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 |
There was a problem hiding this comment.
✅ 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.
regionalRehomeSafetyFailureno longer gates on pool pressure — the check atregional-rehome-safety.ts:50is gone;pool_waiters_max/pool_wait_ms_maxare 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 —
regionalRehomeCellSafetyIsCleanstill 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…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.

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
regionalRehomeSafetyFailurereturneddatabase_pool_pressurewhenever 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,pauseRegionalRehomeForSafetywould 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:
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.tsagainst a freshpostgres:16-alpinecontainer: 73 tests passed.cd cloud/apps/relay && pnpm typecheck: clean.Tests:
still fails closed on each pool pressure boundis 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 pressureis inverted intodefers 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.Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand 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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)