Skip to content

feat(relay): cell reserve mode: book, admit and demote without the database (off) - #27041

Merged
Jinwoo-H merged 1 commit into
mainfrom
relay-step5-cell
Oct 10, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
relay-step5-cell

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​609 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​597
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​511 $\color{#cf222e}{\Huge{\mathbf{−}}}$​55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​456

ELI5

This is the cell half of "desktops connect without the database". When a cell is switched to reserve mode, a director asks it to hold a seat for a desktop, and the cell lets that desktop in without reading the database. Switched off (the default), nothing changes.

What Changed

All behind the per-cell admitMode switch in the cell's Cloud Storage switch file (default db, today's path; flipping back takes effect at the next 5 s read):

  • POST /internal/reserve (directors' rehome credential, like the seat feed). Each booking holds one connection unit until its hello or a 30 s TTL. The cell refuses full at the director's own placement ceiling (cellPlacementCeiling(hardCap, unobservedBound), never above the socket ceiling), intake when its token bucket is empty (intakePerSec switch; 5/s US, 2/s Asia by default; burst 20), draining, seated-newer {epoch}, or off outside reserve mode. dryRun checks without booking, for the shadow latency gate.
  • Hello admit order in reserve mode: (1) a booking at that epoch; (2) a seat this cell held at that epoch in the last 10 min, unless it left for a drain (4503) or a demotion (4409); (3) a valid lease when ticketCheck=enforce (dark); (4) today's database check.
  • No database writes for a control admitted from memory (rules 1–3): no activateControl, no migration-target mark, so it has no lease to renew or release. A control admitted by rule 4 is registered, renewed and released exactly as today. The census PR makes the sweeps skip switched-on cells, and the rollback PR registers the memory-admitted controls on a flip back.
  • Upgrade: the database-pool hello shed (fix(relay): refuse host hellos fast when the database pool is timing them out; renewals jump the queue #26362) skips booked and recently seated hosts, since they need no database; a booked host's control upgrade may rise to the hard cap (its unit is already counted below the ceiling); a full cell's 503 carries Retry-After: 2.
  • POST /internal/demote {epoch, joinedAt}: stops phones for that exact seat now and closes it with 4409 after 60 s. Repeats are one demotion; a rejoin of the same host is a different seat.
  • Seat feed (lenient, old directors ignore all of it): reserve entries, reservedBy on the join a booking admitted, counts.bookings/units/ceiling, intake, and recentlyLeft in full snapshots.
  • Switch file: admitMode, intakePerSec, ticketCheck: enforce.

Why

The design (§3.2–3.3, §10.1) puts only booking, admitting and reporting in the cell, so every choice can change with a director deploy instead of a ~20 h cell update.

Mixed versions. A pre-step-5 cell ignores the new keys; but ticketCheck: "enforce" is a bad value to it and voids its whole object (it keeps its last values), so the flag workflow must not write enforce to an old image. A pre-step-5 director never polls these fields and never reserves.

Deviations from the design.

  • The design skips activateControl and renewals for every control in reserve mode. Here only memory-admitted controls skip them; a control the database admitted keeps today's lease. That way a cell switched on while some director does not know it degrades to today's behaviour for every host that director placed, instead of leaving them with no lease for the database sweeps to misread. As desktops reconnect through bookings and sticky answers, the cell's per-control writes fall to zero anyway.
  • "Skip every relay_cells write" is scoped to controls. Phones still go through today's database path (acquireActivity writes the cell row), as §1 says phones are unchanged in step 5; heartbeats still write, or the cell would look dead.
  • A hello that falls to rule 4 with the database down closes 4429 (today's behaviour, the desktop retries this cell), not 4409.

Linked Issue

N/A (internal relay redesign, step 5).

Visual Proof

N/A: server-side, no UI.

Testing

  • cell-reserve-admission.blackbox.test.ts: a real cell whose Postgres pool is wedged and the hello shed armed. A booked host connects at its epoch only; a stranger is shed; a host that just left rejoins from memory at the same epoch but not at another; with the switch off a booking made while it was on is not honoured; demotion names one exact seat.
  • Route, ledger, seat-log and switch-file tests; the full relay suite passes locally.

…tabase (off)

Rebased onto main as one commit after its parent squash-merged.
@Jinwoo-H
Jinwoo-H changed the base branch from relay-step5-core to main October 10, 2026 06:03
@Jinwoo-H
Jinwoo-H merged commit d488ce5 into main Oct 10, 2026
28 of 46 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