Skip to content

fix(relay): keep connected hosts on a reserve cell set to existing-only - #30609

Merged
Jinwoo-H merged 1 commit into
mainfrom
relay-reserve-cell-stranded-guard
Oct 19, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
relay-reserve-cell-stranded-guard

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

ELI5

When a relay cell is set to "existing hosts only" (we do this during a roll), the director has a safety rule that moves hosts off it if they look like they never managed to connect. On a cell running in the new reserve mode, that rule misread every connected host as "never connected" and would move them, disconnecting desktops that were working fine.

What Changed

The "stranded host" rule in assignment-store.ts now stops early for any cell that is, or may be, in reserve mode (the same "unknown counts as reserve" test the other reserve guards use).

Before: a reserve cell switched to existing-only between 1 and 15 minutes after its ledger last wrote a host's row had those hosts re-placed on another cell on their next assign, because the cell keeps no activity rows and the ledger's write looks like a fresh grant with nothing behind it.

After: those hosts keep their pin. A reserve cell that has actually died is still handled by the existing dead-reserve-cell path, which requires a fence proof; the stranded rule used to skip that check by declaring the cell live.

Why

The rule's evidence (recent last_activity_at, zero live activity leases) only means something on a cell that writes activity rows. Reserve cells never do, which is the same reason completeEvacuation and dormancy already refuse or skip them. Guarding inside the rule fixes all three callers (sticky assign, full assign, isolated-incumbent check) at once. Refusing existing-only on reserve cells instead would block rolls, and existing-only is otherwise fine for them.

Other readers that treat zero leases as idle were checked and are already guarded: idle regional rehome filters reserve cells, evacuation start/status/completion and dormant rebalance refuse them, and migrations cannot exist on a reserve cell.

Deploy: director only; no cell roll needed.

Linked Issue

N/A (internal follow-up from the step-5 placer design review)

Visual Proof

N/A: relay director logic, no UI.

Testing

  • Automated tests added/updated: new census test reproduces the bug (fails on main: host moves to cell-b at epoch 2) and passes with the fix, for both a known and an unreadable reserve set.
  • vitest run --project=relay --maxWorkers=2: 115 files, 1188 passed. Relay tsc --noEmit clean. Postgres-backed tests not run locally (no test database).

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A for visual proof with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote impact: N/A (server-side)

…xisting-only

A reserve cell keeps no activity rows and its ledger stamps last_activity_at, so the
stranded rule read its connected hosts as unserved and re-placed them.
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The stranded-cell check now excludes cells that may be in reserve mode. A new test checks that the assignment retains its existing cell and epoch after activity lease rows are deleted, and that the epoch remains unchanged when the reserve-mode set is unreadable.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 4c51f

The change keeps connected hosts pinned to reserve cells set to existing-only in the normal case. However, if another relay instance switched the cell to reserve mode and reserve-mode reads then fail for over a minute, this instance can rely on an outdated view. It may move connected hosts off the cell. This failure path should be closed before merging.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the main change: keeping connected hosts on a reserve cell set to existing-only.
Description check Passed The description covers the change, rationale, linked-issue context, visual proof, and testing. It is mostly complete; the Review and Agent skill upstream boundary sections are not filled out, but they…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
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 covers the change, rationale, linked-issue context, visual proof, and testing. It is mostly complete; the Review and Agent skill upstream boundary sections are not filled out, but they do not prevent understanding the change.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • 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

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: e41d887b-dad6-4862-a13d-f719aced8373
📥 Commits

Reviewing files that changed from the base of the PR and between b331710 and 4c51fa6.

📒 Files selected for processing: 2
  • cloud/apps/relay/src/assignment-reserve-mode-census.test.ts
  • cloud/apps/relay/src/assignment-store.ts

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

}
// A reserve cell keeps no activity rows and its ledger stamps last_activity_at, so zero
// leases proves nothing; a dead one is left to the dead-reserve path and its fence.
if (await this.mayBeReserveCell(text(existing, 'cell_id'), transaction)) {

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Do not use a stale reserve set as proof that a cell is database-mode.

If this store cached a cell as database-mode before another store switched it to reserve mode, mayBeReserveCell can return false from that stale set after reserve-mode reads fail for more than a minute. When the reserve cell has no activity leases, this guard then allows a connected host to be classified as stranded and moved. Treat an unavailable fresh reserve read as insufficient evidence for stranded reassignment, and test a store with a stale pre-switch cache.

@Jinwoo-H
Jinwoo-H merged commit cb82bc8 into main Oct 19, 2026
24 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