Skip to content

island spares: settle without clocks, unconfirmed rollback stops quarantine the spare (#885 follow-up) - #920

Open
michaellchung wants to merge 3 commits into
mainfrom
own/island-spares-followup
Open

michaellchung wants to merge 3 commits into
mainfrom
own/island-spares-followup

Conversation

@michaellchung

@michaellchung michaellchung commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #885 (own-cluster group 4, spare nodes for resident ssh trainer islands): the low-severity review items of its fifth review, and the fixes of this PR's own review.

  • An unconfirmed rollback stop quarantines the spare. When the start on a spare fails after it began there, and the stop of that incarnation is not confirmed (for example the kill ends rc 1), the spare is no longer given back to the pool. It is treated as a lost node: quarantined with the stop it owes (owed) and the lease holder, that stop in an owed ledger row of its own (priced as that node, open until the stop is confirmed), its claim given up (the record keeps every island off it) and its lease kept. The incarnation's own row closes when only such spares failed to confirm. No island of this run or another can pick it until yeto cluster release-node; once released, any island can.
  • settle compares no clock. It creates its marker (fleet/nodes/<name>/settled/), then reads the quarantine record again. If the record no longer lists that stop (released, or quarantined anew), it removes the marker, so none is left behind. A record that only gained another stop keeps the marker. The released.json time is no longer read; it stays in the run store as a record of the release.
  • A failed start keeps its incarnation number. The next try starts the next incarnation (one past the newest in the jobs journal), so a failed start's dirs and ledger row are never reused; an incarnation not confirmed stopped on a node is carried back to the old islands and into the next try, which stops it there before it starts.
  • Marker names cannot collide. Each field (run, island, incarnation) is urlsafe base64 without padding, joined with ., which never appears in the encoding.
  • release-node. It writes no tombstone into the lease store, since nothing reads one there. A store or ledger failure during the release is reported as a message with exit 1 instead of a traceback, and the record stays.
  • Lease holder on every spare quarantine. A spare refused for its place, or whose start failed, is quarantined with the lease holder, so release-node can end that lease.
  • Claims of unused picks. A pick whose lease step raises gives its claim back, and the next candidate is tried. When a later pick of the same replacement raises, the picks so far are given back.
  • Owed stops before the start, outside the lock. The owed stops of a candidate with open owed rows (released elsewhere) run synchronously in its candidate checks, outside the ops lock and before any island starts on it; one stop per node at a time (two islands' checks stop it once). A candidate whose stop fails is passed over this round with the reason. A row closes only after its stop succeeded.
  • owed_kill_script quoting. Each path word of the trap is quoted (the state home expands at the trap, the rest is literal), and the trap is one shell word: a run or island name with ", $(...), backticks or ' expands nothing there. (kill_script itself, shared with the golden-locked launch scripts, still double-quotes its paths; such names are not validated today.)
  • Read failures. A record the store fails to read is unreadable (with read_error): it counts as quarantined, _owes and _still_owed take its stops as owed, quarantine() refuses to write over it, and release-node asks to be run again later (not --force). When only the settled markers cannot be listed, the record comes back unfiltered with read_error (every stop owed; each is idempotent) and still counts as quarantined at a start. release() removes the record before the markers; a settle whose second read raises removes its marker. A loss whose quarantine cannot be written keeps the island's claim.
  • Rollback covers the steps after the pick. The new islands, health watches and lease record are set up inside the rollback's try; a failure there gives the spares back.
  • For the add-island check. node_quarantine.run_store_quarantines(objects, names, *, log=None) reads a run store's quarantine records the way shared_quarantines reads a lease store; an unreadable record counts. node_quarantine.trainer_pick_excluded(names, *, lease_objects=None, run_objects=None, assigned=(), log=None) -> (excluded, quarantines, note) is the trainer pick's exclusion set. lease_trainer_nodes uses it with the run's lease objects, assigned and the run store's objects (_run_store_objects(args)), so a prediction made with the same arguments matches the pick.
  • Docs. The release section of docs/OWN_CLUSTERS.md states the settle and rollback behaviour.

Tests

tests/test_ssh_island_spares_recovery.py, new cases:

  • Settle:
    • with release-node's clock an hour ahead of or behind the launcher's, a node released, picked again and lost again settles its new stop and owes no row;
    • a release between the marker and the second read leaves no marker;
    • a release plus a new quarantine there leaves no old marker;
    • a record that only gained a stop keeps the marker;
    • a stop the record never listed gets no marker;
    • marker names of six look-alike stops are distinct.
  • Release:
    • no lease-store tombstone;
    • release-node with a failing store, and with a failing ledger, exits 1 with a message;
    • the record is removed before the markers; a settle whose second read raises removes its marker.
  • Read failures (REV-920 P5, P8):
    • markers that cannot be listed: every stop listed stays owed, a second quarantine keeps the first stop, a start still takes the node as quarantined, release-node asks to be run again later;
    • a record that cannot be read: its stop is run, quarantine() does not write over it, release-node asks to be run again later;
    • a loss whose quarantine cannot be written keeps the island's claim.
  • Rollback (reproduction): a spare whose rollback kill returns rc 1:
    • is quarantined with the owed stop of that incarnation and the lease holder, its lease kept, its claim given up; another island's pick leaves it out as quarantined;
    • (P1) once recovered and released, and the island down, another island picks it;
    • (P11) its owed row stays open through down() until release-node confirms the stop; the incarnation's row closed;
    • (P2) a rollback stop not confirmed on an old node: the next try is incarnation 2 and stops 1 on that node before starting 2.
  • After the pick (P9): the new health watches failing gives the spare's claim and lease back and leaves the island on its old nodes.
  • Lease holder: a spare whose start failed, and a spare refused for its place, are quarantined with the lease holder.
  • Picks:
    • a lease step that raises gives the claim back, and the next spare is taken;
    • a later pick that raises gives the earlier picks back.
  • Owed stops (P10): the owed stop of a candidate released elsewhere begins and ends before incarnation 2 starts on it, without the ops lock held; two concurrent checks of one candidate stop it once; a candidate whose owed stop fails is passed over with the reason and its row stays open.
  • Stale leases: a stale lease of a quarantined node is kept; a stale pick whose lease this launcher does not hold is not released.
  • Quoting: the owed stop with a single quote in the island name, run by bash, stops the group and leaves the marker; the trap with ", $(...), a backtick or ' in the name passes bash -n, expands nothing and writes the marker at the literal path.
  • Run-store exclusions: the trainer pick leaves out a node quarantined in the run store only.
  • Exclusions: run_store_quarantines and trainer_pick_excluded cover broken JSON, read errors, listing failures, the union with the lease store and assigned, and the note.

Results:

  • Mutation: 48 of 48 mutants of this PR killed (the 24 REV-885e ones re-anchored, 24 for REV-920):
    • REV-885e: settle (no second read, the tombstone clock, the marker kept for any record, old marker names), release (the lease-store tombstone, store errors raising), own read errors raising, picks (the lease error keeping the claim or raising, the picks kept on a later error), the unconfirmed spare (unpicked, owing nothing, its lease not kept, the release result ignored), the lease holder on three paths, exclusions (assigned, the run store, a listing failure, the wrong key, the trainer pick ignoring the set), the stale-lease quarantine guard;
    • REV-920: the unstopped spare keeping its claim, without its row, the incarnation row kept open; the incarnation number reused, unreleased not carried back or forward; a listing failure filtering everything or counting as unreadable, _still_owed and _owes skipping unreadable, quarantine() writing over an unread record, release-node forcing on a read error, a start skipping a listing-failure record, a failed quarantine giving the claim up; the owed stop not run in the checks, a failed one still a candidate, no per-node lock; markers removed before the record, a marker kept when the second read raises; the health watches outside the try; the trap words unquoted or not one word; the trainer pick without the run store; a stale lease not held released.
  • Whole python suite locally on this head's tree, as CI runs it (4 shards, --timeout=600, one process per shard, on base b65c3a0; the rebase onto 1a5d22f adds two test files only, rerun here with the spares files: 190 passed): 18505 passed, 377 skipped, 11 xfailed; one failure outside this change, test_bulk_resend.py::test_slow_receiver_of_a_rejoin_catch_up_does_not_stall_rounds_or_leases[inline-old-behavior] (a syncer timing test; reported, not rerun). The real-syncer spares e2e passes in its shard.

Customer gate

  • 52 customer goldens: 52 passed.
  • examples/k31 dry runs (run up and nc pool): 6 of 6 normalized outputs (4 run up dry-run and preflight logs, 1 nc pool dry-run, the golden file diff) identical to main line by line.

🤖 Generated with Claude Code

@michaellchung
michaellchung force-pushed the own/island-spares-followup branch from f5b60b9 to 4b047ed Compare November 26, 2026 21:35
michaellchung and others added 3 commits November 27, 2026 06:19
…antine the spare

- A spare whose start failed and whose stop of that start is not confirmed is
  treated as lost: quarantined with the stop it owes and the lease holder, its
  claim and kept lease held, so no island of any run picks it.
- settle creates its marker, then reads the record again and removes the
  marker once the record no longer lists that stop; no tombstone clock is
  compared. Marker names encode each field (urlsafe base64, dot-joined).
- release-node writes no tombstone into the lease store; a store or ledger
  failure is a message and exit 1, not a traceback.
- Spare quarantines (refused, start failed) carry the lease holder.
- A pick whose lease step raises gives its claim back; the picks so far are
  given back when a later pick raises.
- The owed stops of a node picked again run in the background, outside the
  ops lock; owed_kill_script quotes its trap for any name.
- own_quarantine turns read and listing failures into an unreadable record.
- node_quarantine: run_store_quarantines and trainer_pick_excluded (the trainer
  pick's exclusions, shared with a pick prediction).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arnation numbers, synchronous owed stops)

- A spare lost at a rollback gives its claim up (its quarantine keeps every
  island off it), gets an owed ledger row of its own, and the incarnation's row
  closes when only such spares failed to confirm.
- A failed start keeps its incarnation number; an incarnation not confirmed
  stopped on a node is carried back to the old islands and stopped first at the
  next try.
- A settled-marker listing failure returns the record unfiltered with
  read_error; _owes and _still_owed count an unreadable record as owed;
  quarantine() never writes over a record it could not read; release-node asks
  to be run again later on a read error.
- The owed stops of a candidate released elsewhere run synchronously in its
  checks (outside the ops lock, before any start), one per node at a time; a
  candidate whose stop fails is passed over with the reason.
- release() removes the record before the markers; a settle whose second read
  raises removes its marker.
- The steps after the pick run inside the rollback's try.
- The owed stop's trap quotes each path word; the trainer pick also reads the
  run store's quarantines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arantines kept in memory

- down() releases every earlier incarnation not confirmed stopped on a node
  (a failed start on spares) before the current one; while one is not
  confirmed it returns False and the island keeps its leases, claims and rows.
- A quarantine the store refuses is kept in memory (IslandSpares.pending): the
  node is left out of this island's picks, owes its stops (_owes, _still_owed;
  a lost node also gets its owed ledger row at once), keeps the island's claim,
  and every check and down() writes the record again, then gives the claim up.
  A confirmed stop drops its owed row from the pending quarantine.
- A candidate whose run ledger cannot be read is passed over this round
  (release_owed_elsewhere(strict=True) raises LedgerUnread).
- Tests for each reviewer counterexample and mutant: a rollback whose only
  unconfirmed stop is a lost spare carries no unreleased incarnation; an
  unhealthy candidate runs no owed stop; an owed stop that raises passes the
  candidate over; two refused quarantines of one node owe both stops.
- Docs: the candidate checks have no overall deadline; down() and refused
  quarantines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michaellchung
michaellchung force-pushed the own/island-spares-followup branch from 4b047ed to 140e96a Compare November 26, 2026 22:22
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