Skip to content

fix(relay): never cache a region hint from a one-region catalog - #19349

Merged
Jinwoo-H merged 2 commits into
mainfrom
relay/no-hint-on-one-region-catalog
Sep 7, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
relay/no-hint-on-one-region-catalog

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​30 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​24
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

Replaces #19322, reduced to the one rule that fixes a reproduced bug. Everything else that PR accumulated over six review rounds (warm-up budgets, incumbent holds, cache markers, self-heal fences, log reason reordering, warning aggregation) is dropped: each of those was a heuristic that invited the next counter-heuristic, and none fixed a reproduced production problem.

Why

The director lists only regions that currently have a serving cell, so a roll wave shortens the catalog to one entry. On main the resolver requires only every listed region to be measured, so that lone region wins against nothing and is cached as a 24 h hint. A US desktop refreshing while US cells roll publishes asia-east2 for a day, which is exactly the incident #19233 ended. Two tests on main pinned this behaviour.

What

One condition: fewer listed regions than the fleet serves withholds the hint, the same 1 h no-hint outcome main already uses for an unmeasurable peer. No new state, no new cache fields, no new log reasons. The cost is bounded and known: a desktop that refreshes during the other region's roll wave loses its hint for one hour and lands at the director default, which is us-central1, the region most desktops want anyway.

Diff

relay-region-preference.ts: +3 lines of condition, one comment. The two tests that asserted a lone-region hint now earn it against both regions; their intent (corrupt-cache recovery, expiry bound) is unchanged. One new test: one-region catalog yields no hint with the 1 h TTL, and fails without the fix.

Verification

pnpm vitest run src/main/runtime/relay/ 156/156, pnpm tc:node, oxlint and oxfmt clean.

The director lists only regions with a serving cell, so a roll wave shortens the
catalog to one entry. The resolver required only every *listed* region to be
measured, so that lone region won against nothing and was cached for 24 h: a US
desktop refreshing while US cells rolled published asia-east2 for a day, the
incident #19233 was written to end. Now fewer listed regions than the fleet serves
withholds the hint (1 h no-hint TTL), the same outcome as an unmeasurable peer.
@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: aacd045e-664c-445b-88d7-dc9cc8f3b31f

📥 Commits

Reviewing files that changed from the base of the PR and between 1d1b73c and b307658.

📒 Files selected for processing (2)
  • src/main/runtime/relay/relay-region-preference.test.ts
  • src/main/runtime/relay/relay-region-preference.ts

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


📝 Walkthrough

Walkthrough

Relay region selection now withholds a hint when the director catalog lists fewer regions than the known relay regions. It writes a one-hour no-hint cache entry in this case. Tests now use two-region catalogs for fallback, corrupt-cache recovery, and cache-expiry scenarios. A new test verifies the incomplete-catalog behavior and its cache contents.

Merge Risk: ⚪ Minimal · up to b3076

Incomplete relay catalogs now produce a short-lived no-hint result instead of pinning users to the lone reported region. The intended cache behavior is covered, with no remaining concrete merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description clearly explains the bug, the fix, the scope, and verification results. However, it omits most required template sections, including ELI5, What Changed, an explicit Linked Issue entry,… Complete the repository template. Add the missing required sections and provide an explicit issue reference such as Fixes #19333``, state N/A for Visual Proof with a reason if applicable, document manual and automated testing with platfor…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the primary change: preventing region hints from being cached when the catalog contains only one region.
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 2…
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 clearly explains the bug, the fix, the scope, and verification results. However, it omits most required template sections, including ELI5, What Changed, an explicit Linked Issue entry, Visual Proof or N/A, Testing checkboxes, Review, Agent skill upstream boundary, Notes, and the Checklist.

Resolution

Complete the repository template. Add the missing required sections and provide an explicit issue reference such as Fixes #19333``, state N/A for Visual Proof with a reason if applicable, document manual and automated testing with platform coverage, and complete the applicable checklist items.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 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

One added condition in RelayRegionPreferenceResolver.refresh() plus matching test updates, so a region hint is only produced when the director's catalog lists every region in the fleet.

  • relay-region-preference.ts — refresh() appends reports.length < RELAY_REGIONS.length to the existing measurements.length < reports.length guard, so a catalog listing fewer regions than the fleet serves (a roll wave) withholds the hint for the 1 h no-hint TTL instead of caching a lone survivor for a day. No new state, cache fields, or log reasons.
  • relay-region-preference.test.ts — two tests that previously asserted a lone-region hint now measure both regions; one new test pins the one-region-catalog case to a region: null 1 h cache and fails without the fix.

The new test genuinely guards the bug: with a healthy one-region catalog, the old code selected and cached that region, so .resolves.toBeUndefined() and region: null both fail pre-fix.

ℹ️ RELAY_REGIONS.length is now a load-bearing "fleet size" proxy

The condition compares the catalog length against the desktop's compile-time RELAY_REGIONS.length, so correctness now assumes the desktop's region list stays in lockstep with the director's actual serving set. Those lists are maintained independently (desktop relay-region-probe.ts vs. the relay's own RELAY_REGIONS), so a version skew where the desktop lists more regions than the fleet currently serves would withhold every hint fleet-wide until the skew resolves. Harmless for the current two-region fleet, but worth remembering if a region is ever added or removed.

Technical details
# Desktop region list vs. director serving set must stay in lockstep

## Affected sites
- src/main/runtime/relay/relay-region-preference.ts:185 — `reports.length < RELAY_REGIONS.length`

## Required outcome
- No change needed for the current fleet. When a region is added, the desktop's `RELAY_REGIONS`
  list and the director's serving set must ship so the count matches while that region is rolling out;
  otherwise all desktops fall back to `us-central1` for the skew window.

## Open questions for the human (optional)
- Is there an intended future region rollout order that would trigger this skew?

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

@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 review, one follow-up commit tightened a test the fix itself had quietly weakened.

  • relay-region-preference.test.ts — the "unstable probes" section of 'falls back without a hint for corrupt cache, old catalogs, and unstable probes' now measures a two-region catalog (flapping US [15, 10, 20, 400] against stable Asia [300, 200, 205, 210]), so its toBeUndefined() is attributable to the US path's spread rejection alone, rather than also passing against the new one-region-catalog rule. Before this change the single-region US catalog would have been swallowed by reports.length < RELAY_REGIONS.length, leaving the flap-rejection assertion with no independent teeth.

The change is test-only (3 insertions, 2 deletions); production code is unchanged. pnpm vitest run src/main/runtime/relay/relay-region-preference.test.ts passes 26/26.

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

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