Rolling out to a large cluster

On this page

A roll (Hotcode.Rollout) is driven by one node: it asks every node for a preflight, then deploys to them one at a time with a health check after each. For ten nodes that is right. For two hundred nodes it is one process making four hundred calls in a row, a lock over every node for the whole time, and an operator watching it. This guide describes the other way: the release is deployed to a few canaries, and once they have been healthy long enough the nodes pass it to each other, each one deciding for itself from what it sees of the cluster.

The analogy, used only in this guide: the canary is patient zero, a canary that passes becomes a spreader, and every node it reaches is infected and may pass it on. The API uses plain names: :canary, :spreader, :upgraded, :pending, :failed.

It is opt-in on both sides. The signers put a rollout policy inside the signed statement (--rollout-* flags), and the nodes run convergence: [mode: :spread]. Without both, nothing here happens, and mix hotcode.deploy rolls as it always did.

In short

# 1. build and sign a release with a policy (shown to every co-signer as ROLLOUT: lines)
mix hotcode.build app@10.0.0.1 --out r7.hcp --version r7 --ttl-minutes 240 \
  --rollout-canary 2 --rollout-soak 10m --rollout-success 0.99 \
  --rollout-max-unavailable 10% --rollout-halt-failures 3 --auto-rollback-after 15m
hotcode sign r7.hcp --key alice.key && hotcode sign r7.hcp --key bob.key

# 2. deploy it to the canaries only: an ordinary signed roll over two nodes
hotcode push r7.hcp app@10.0.0.1 --canary 2

# 3. wait: 0 done, 5 halted, 6 still going when the time ran out
hotcode wait app@10.0.0.1 --timeout 120m

Between 2 and 3 nobody does anything. The canaries soak, promote themselves, and the other nodes pull the release from them, at most 10% of the cluster at a time. To pick the canaries or pace the spread by something you know about your nodes (a region, an availability zone, a tier), give the nodes metadata and name it in the policy.

Roles and states

Each node has a role for the release at the head of the cluster, and a stage within it. Both are published with the node's status (see What a node publishes).

role stage how a node gets there what it does leaves when
:pending :idle, :waiting it sees a release with a policy that it does not run waits for a spreader, its group's turn (with group_by) and a free slot it takes a slot and starts a pull
:pending :upgrading it holds a slot of its group's cap fetches the signed envelope from a source, deploys it through its own loader, runs the health check the deploy and the check end
:canary :soaking it runs the release and nobody has promoted it yet (the operator deployed it here) samples canary_check every sample_ms soak_ms passed with the share of good samples at success (:passed), or deadline_ms passed first (halt)
:canary :passed its soak passed waits for every reachable canary to pass, at least min_canaries, and for a signed promote if the policy says require_promote then it promotes itself
:spreader :live a canary that promoted itself serves the envelope to pulling nodes, fanout at a time a new release
:upgraded :live a pending node whose pull and health check passed (or a node that came back with the release after a restart, once its health check passed) serves the envelope like a spreader a new release
:pending :waiting, says push: true its pulls reached no source push_after_attempts times, or it may not pull (spread: [pull: false]) waits for its designated pusher a push is accepted (then as :upgrading)
:failed :idle its deploy was refused, or its health check failed and it rolled itself back nothing; it counts toward halt_failures (in the epoch it failed in) a new release; a signed resume retries it if it was refused before loading
any :halted halt_failures nodes failed, or a canary missed its deadline nothing starts; with auto_rollback, the undo starts at once a signed resume (before the undo), or a new release
             operator deploys to the canaries (signed roll over those nodes)
                                   │
 pending ──────────────────────────┼─────────────────────────────────────────────┐
    │                              ▼                                             │
    │                      canary:soaking ──deadline──▶ halted ──(auto_rollback)─▶ undone
    │                              │ soak passed
    │                              ▼
    │                      canary:passed ──all reachable canaries passed,
    │                              │        min_canaries, signed promote if asked
    │                              ▼
    │  promoted, group's turn,   spreader:live ◀── sources ──┐
    │  slot free, jitter          ▲                          │
    ▼                             │ serves fanout at a time  │
 pending:upgrading ──health ok──▶ upgraded:live ─────────────┘
    │
    └──refused or unhealthy (rolls itself back)──▶ failed ──halt_failures reached──▶ halted
                                                                                     │
                     signed resume (before the undo): failures so far stop counting,  │
                     nodes refused before loading are retried, the spread goes on ◀───┘

 pending ──pulls reach no source push_after_attempts times──▶ pending, push: true
         ──its designated pusher pushes, accepted only if it would pull now──▶ pending:upgrading

The release is "done" when every reachable node runs it (past its health check) or failed, and no node is upgrading.

The signed policy

The policy is the field "rollout" of the deploy statement, under the same signatures as the code. Hotcode.Trust checks its shape before a node accepts the statement; a statement without it is byte for byte what Hotcode wrote before the field existed.

field flag default meaning
canary --rollout-canary 2, --rollout-canary-match tier=canary 1 how many canaries; with a match ({"match": {...}, "count": N}), the nodes whose metadata matches: every one, or N of them
min_canaries --rollout-min-canaries N 1 canaries that must pass before any of them promotes
soak_ms --rollout-soak 10m required how long each canary is watched
deadline_ms --rollout-deadline 30m 2 x soak_ms the canaries must pass before this, or the release halts
success --rollout-success 0.99 1.0 (flag) share of good health samples over the last soak_ms
require_promote --require-promote false the canaries wait for a signed promote (mix hotcode.promote)
spread.fanout --rollout-fanout N 4 envelopes one node serves at the same time, pulled or pushed
spread.push_after_attempts --rollout-push-after N 3 pulls that reached no source before a node asks to be pushed
spread.max_unavailable_pct --rollout-max-unavailable 10% 10 share of a group (or of the cluster) upgrading at once, at least one node
spread.group_by --rollout-group-by region none a metadata key: the nodes sharing its value form a group, and the cap is per group. Without it there is one group, the cluster
spread.order --rollout-order any group_by_group with group_by, else any only with group_by (refused without): groups one after the other (the canaries' first, then by value), or all at once
halt_failures --rollout-halt-failures 3 or 5% 1 the release halts when this many nodes have failed

A co-signer sees it in hotcode sign and hotcode describe:

  ROLLOUT:     the nodes spread this release among themselves
    canary:    2 canary node(s), soak 600 s, >= 99.0% healthy (at least 1 passing, by 1200 s), then promote themselves
    spread:    the whole cluster at once; <= 10% of the cluster upgrading at once; each node serves <= 4 at once
    halts at:  3 failed node(s)

The envelope's life bounds the whole rollout. Every node verifies the expiry (--ttl-minutes, 15 by default) when it pulls. A node that pulls after it is refused as :expired, which is final, so it fails, and enough of them halt the release. mix hotcode.build refuses a policy whose canary deadline does not fit in the envelope's life. For a large cluster, size --ttl-minutes to the canary deadline plus the time the spread needs (the simulation below gives an order of magnitude) plus a margin.

Configuring the nodes

config :hotcode,
  convergence: [mode: :spread],
  metadata: %{"region" => "eu-west-1", "tier" => "edge"},  # free-form, or {Mod, :fun, args}
  canary: false,                        # true on the nodes you want picked first as canaries
  canary_check: {MyApp.Health, :canary, []},   # default: Hotcode.Health.check/0
  members_backend: :syn,                # optional, needs {:syn, "~> 3.3"} in your deps
  spread: [sample_ms: 5_000, jitter_ms: 2_000, backoff_ms: 2_000, settle_ms: 0, tick_ms: 500,
           pull: true]                  # false: this node never fetches; it asks to be pushed

canary_check returns :ok, true, false, {:error, _} or a number from 0 to 1 (a share of good requests, for example). It runs on the canary every sample_ms and must be quick. After a pull every node runs Hotcode.Health.check/0 (your health_check) after settle_ms, as a roll does.

Every node must run mode: :spread and the same members_backend: a node in another mode never pulls, and a node on the other backend does not see the others.

Node metadata

A node describes itself with metadata: free-form labels, a map (or keyword list) or an {m, f, a} that returns one, published with its status (Hotcode.Spread.metadata/0). Keys and values become strings; a pair that is not 1 to 64 bytes each, or whose key contains [ or ] (a selector travels as canary_match[KEY][]=VALUE), is dropped, and at most 32 are kept; the node logs one warning when it drops any. An {m, f, a} runs in its own process with 250 ms to answer and its answer is kept for 30 s, so a slow function cannot block the node's status, and one that fails keeps the last answer (a node whose labels flap would change group mid-rollout); see Hotcode.Spread.Metadata. Hotcode gives no key a meaning. A node publishes its own labels and nobody signs them: a compromised peer can claim tier=canary to be picked as a canary or to sit in a group of its own, like any other claim about its status. Treat the labels as hints from nodes you already trust. The signed policy uses them in two places, and only if it says so:

  • picking the canaries: "canary": {"match": {"tier": "canary"}, "count": 2} (--rollout-canary-match tier=canary --rollout-canary 2). A node matches when every key of the match has one of its values ({"region": ["eu-west-1", "eu-west-2"]} matches either). Without count, every matching node is a canary. hotcode push --canary-match KEY=VALUE overrides the match for one deploy, as --canary N overrides the count. A --canary-match without --canary makes every matching node a canary, whatever count the policy had: pass --canary N with it to keep the set small;
  • grouping the spread: "spread": {"group_by": "region"} (--rollout-group-by region). The nodes sharing a value form a group (those without the key form one more group); the cap max_unavailable_pct applies per group, the groups go one after the other unless order: any, a node pulls from its own group first, and the majority a node needs to start an upgrade is its group's.

The key can be anything you know about your nodes: a region, an availability zone, a rack, a tier, a customer cohort. config :hotcode, canary: true on a node still puts it first among the canaries picked.

What a node publishes

Every node keeps a table of every node (Hotcode.Cluster.Members), and the spread is decided from it. Two backends fill it (Hotcode.Cluster.Members.Backend):

  • the built-in one: each node casts its status to its peers when it changes and probes every node every interval_ms. That is N calls per node per interval: fine for tens of nodes;
  • :syn (members_backend: :syn): each node joins the group :nodes of the scope :hotcode (syn_scope:) with its status as metadata, and joins again when it changes. :syn sends each change to every node of the scope and removes a node's entry when it disconnects. Reading the table costs nothing on the network. Hotcode never installs a :syn event handler (an application has one, and Realtime has its own).

The entry of a node in the table is the map Hotcode.Loader.status/0 returns, trimmed:

%{version: "r7", history: ["r7", "r6"], releases: ["r5"],
  head: %{version: "r7", seq: 1_767_225_600_000, rollout: %{...}, auto_rollback: %{...},
          requires: [], applied_at: ...},
  required: [], metadata: %{"region" => "eu-west-1", "tier" => "edge"},
  spread: %{version: "r7", seq: 1_767_225_600_000, role: :upgraded, stage: :live,
            health: nil, canary: false, reason: nil, updated_at: 1_767_225_700_000}}

head is the signed patch on top of the node's stack, with the policies its verified statement carried. spread is what the node says about the release it works on. updated_at is wall time, for people and for the time-left hint; no decision depends on clocks agreeing across nodes.

How the spread runs

Every tick_ms each node in :spread mode calls Hotcode.Spread.Plan.decide/4 with its table and its own state, and carries out the answer. There is no coordinator for the spread itself.

  1. The release. The head of the reachable nodes' lineage (the release every other one is in the history of, Hotcode.Cluster.Members.lineage/0) if its signed statement carries a policy. A fork (two releases neither in the other's history) is never spread.
  2. Canary. A node that runs it with no role and sees no spreader becomes a canary and soaks.
  3. Promotion. A canary that passed promotes itself when every reachable canary has passed (one still soaking may yet fail and is not overruled), at least min_canaries of them, and, with require_promote, after a signed promote reached it.
  4. Pull. A pending node waits until it sees a spreader, its group's turn (with group_by and group_by_group: every reachable node of the groups before it runs the release past its health check, or failed), fewer than the cap of its group saying :upgrading, and a strict majority of its group's known nodes reachable (so on a partition only one side of a group upgrades, and the two sides never each use the whole cap). Without group_by its group is the cluster. Then, after a random wait of up to jitter_ms, it takes a slot: a :global lock among its group's nodes, one of cap of them. Under the slot it asks every node of its group directly what it says about the spread (an ETS read on each, whatever the backend): the node that held the slot before wrote its outcome there before it gave the slot up, so a failure in the group is never missed, however late :syn brings it. If the release is halted, it backs off. Then it says :upgrading, takes its own roll lock, and fetches the envelope from a spreader or upgraded node of its group (any group if its own has none yet). A source serving fanout already answers :busy and the puller tries another, then backs off.
  5. Verify and deploy. The bytes go through the puller's own Hotcode.Loader.deploy_binary/2 with every check of a deploy (threshold, audience, expiry, replay, base, requires, module policy, analyzer, hooks), plus two: the statement must carry a rollout policy, and it must be the release the puller expected ({version, seq}). A node that lacks an intermediate release pulls every release of the head's line it lacks, in order, each verified the same way; each must carry a rollout policy too (one without is refused, and the node fails).
  6. Health gate. settle_ms, then Hotcode.Health.check/0. Healthy: :upgraded, and it serves others. Unhealthy: it rolls back that release (only that one, by version and seq) and is :failed. The pull keeps its slot until its outcome is published, so the next node of the group sees it before it can start.
  7. Push, the fallback. A pull that reaches no source (none answered, none had the envelope, all were busy) counts; after push_after_attempts of them (signed, default 3), or at once on a node configured spread: [pull: false], the node says push: true. One source of its group (any group if its own has none), chosen by a hash of the node's name, is its pusher: no stampede, no node pushed twice at once. The pusher reads the envelopes the node lacks from its own store, counts the push against its own fanout, waits backoff_ms between pushes, and calls the node's Hotcode.Spread.accept_push/3. The node accepts only if it would pull that release itself right now (Plan.decide/4 answers a pull: same {version, seq}, not halted, not superseded, its group's turn, its group under the cap), and then runs exactly the pull's steps (slot lock, the re-read under it, its own roll lock, its own verification with the policy and the expected {version, seq} required, the health gate, its own rollback on failure). A pushed envelope its loader refuses does not make it :failed: unsolicited bytes cost it nothing ({:skip, {:push_refused, version, reason}}, audited as a rejection).
  8. Halt. When halt_failures nodes have failed, or a canary missed its deadline, every node that sees it marks the release halted: no pull or push starts any more. Those already running finish.
  9. Undo, at once. If the halted release's statement carries auto_rollback, the lowest-named reachable node running it starts the undo as soon as it sees the halt: it does NOT wait for the signed after_ms, which stays the deadman's deadline for a cluster that cannot follow a release without a rollout policy (mode: :auto). The rails are the deadman's: a strict majority of the table reachable, no unreachable node last seen on it, no node whose stack requires it, the roll lock taken on every node involved (which no pull can be holding), the head only, never twice. Under the lock it checks the release is still halted (a resume takes the same lock), reads again which nodes run it, and undoes it on every one, each through its own Hotcode.Loader.auto_rollback/2. Without auto_rollback the halted release stays where it is until a signed resume or a signed rollback.
  10. Resume. hotcode resume TARGET --key ... sends a signed resume (threshold, audience, expiry, bound to {version, seq}, replay-protected by its own seq). The node verifies it, takes the roll lock on every reachable node (the undo's lock), checks the release is still at the head and halted, and delivers it to every node, each verifying it again. Then: halts and failures said before it no longer count (each node keeps the resume's seq as an epoch, and a failure counts only in the epoch it happened in), halt_failures applies afresh, a canary that missed its deadline soaks again, every node refused before loading is retried, and every node that loaded the release and rolled it back after its own health gate is retried once: it has used that statement's seq up, so its loader arms ONE more acceptance of exactly that statement (Hotcode.Loader.allow_retry/2), and only because a resume it verified itself asked for it. The replay counter is not lowered; another statement, an older one, or a release undone by anything else (a signed rollback, a roll, the deadman's or a halted spread's undo) is never re-applied this way. A restart forgets the arming. A node that already runs the release decides from the rollout policy of its own verified stack entry, never from a row in the table. When rows disagree about the policy for the same {version, seq}, the release halts with {:policy_conflict, nodes}. Once a node has verified a resume, a row's epoch counts only up to that resume's seq, so a forged epoch cannot keep a release halted.
  11. Done. Every reachable node runs it, past its health check, or failed.

Resume and undo, the race. Both take the roll lock {Hotcode.Rollout, _} on every reachable node, without waiting. If the resume holds it first, it is delivered everywhere before the undo can start, and the undo, once it gets the lock, finds the release no longer halted and does nothing. If the undo holds it first, the resume is refused with {:busy, :roll_lock}; once the undo is done the release is gone and a resume is refused with :undone. There is no state in which some nodes resumed and others were undone.

All of it is derived from the table and the stores: a node that restarts finds its role again (it runs the release: :upgraded once its health check passes, or a canary again if nothing was promoted; it does not: :pending).

Rails

rail where
only a release whose SIGNED statement carries a policy is spread, only within it Plan.release/1, Loader.deploy_binary(require_rollout: true)
every pulled envelope is verified by the node that loads it, as any deploy Hotcode.Loader
the puller checks it got the release it expected Loader.deploy_binary(expect: {version, seq})
no node pulls before a canary promoted Plan.decide/4
at most max_unavailable_pct of a group (or the cluster) upgrading a :global lock per slot, among the group's nodes
a source serves at most fanout at once, pulls and pushes together Hotcode.Spread.serve/1, and the pusher's own count
a push is accepted only where the node would pull now, and verified by it Hotcode.Spread.accept_push/3
a halted release resumes only by a signed resume, never after its undo started Hotcode.Trust.verify_resume/2, Hotcode.Spread.resume/1, the roll lock
one deploy at a time per node, never during a roll the roll lock {Hotcode.Rollout, _} on the node
a failure is undone on that node at once Hotcode.Loader.rollback(target_version:, target_seq:)
halt_failures failures stop everything Plan.summary/2, re-checked under the slot
an automatic undo needs the signers' auto_rollback, a majority, the lock, nothing requiring it Plan.undo_plan/5, Members.undo_locked/1
the kill switch and the failure lockout stop a node from taking anything Hotcode.Guard, checked by the loader

Failure modes

what happens what the nodes do
a canary is unhealthy it does not pass; at its deadline the release halts; nobody else pulled. With auto_rollback the canaries are undone
a node cannot pull (no route to any source, no store_dir on the sources it reaches) after push_after_attempts it asks for a push and its designated pusher pushes, under the same caps; if its pusher is down, the next pick of the hash is another source once the table drops it
a pulled node is unhealthy it rolls itself back and is :failed; the next node of its group starts only after it published that
a node refuses the envelope (base, requires, a policy denial, an expired envelope) it is :failed with the reason; refusals count toward the halt like health failures
a node crashes or is cut off while upgrading its slot lock is released with it; the others continue; it is not waited for (only reachable nodes count). If its deploy had committed, its store replays it at boot and it finds its role again
a node joins late, on the old release it is :pending and pulls like the others
a partition each side decides on what it sees. A side with no node running the release does nothing. A node starts an upgrade only when it sees a strict majority of its group's known nodes (of the cluster without group_by): of two sides of a group, at most one upgrades, so the cap holds across the split. A side may report done for the nodes it sees; after the heal the others pull. An automatic undo needs a strict majority: on a split, neither side undoes
two releases overlap the newer one is the head only if it has the older one in its history (built on it). Nodes then pull the missing releases in order. Two releases not in each other's history are a fork: nothing is spread, :cluster_cannot_converge is reported, an operator decides
the envelope expires mid-spread every later pull is refused as :expired: those nodes fail and the release halts (and is undone with auto_rollback)
a roll is running pulls and the undo need the roll lock and wait
a node is locked (Hotcode.lock/0) it refuses; locally that is a refusal, not a health failure

Mixed versions during a spread

During the spread the cluster runs two releases for much longer than during a roll: minutes to hours. Everything in Clusters and mixed versions applies, more so:

  • a change to what nodes send each other takes three releases: readers first, then writers gated by Hotcode.Cluster.applied?/1 and built with --requires on the readers' release, then cleanup. A spread of the writers' release starts only on nodes where the readers' release is live (requires is checked by each node's loader), and applied?/1 stays false until every node has it;
  • with group_by, a call between groups is between a finished group and an unfinished one for most of the rollout: both versions must be able to talk to each other in both directions;
  • a release whose spread halted without auto_rollback leaves the cluster mixed until someone acts. hotcode wait exits 5 and says so.

Configuring Supabase Realtime

Realtime runs one Erlang cluster across regions (libcluster's Postgres strategy), with :syn already started and REGION in its configuration. A configuration that fits it:

# config/runtime.exs
config :hotcode,
  convergence: [mode: :spread, after_ms: 120_000],
  members_backend: :syn,                     # :syn is already a dependency; scope :hotcode
  metadata: %{"region" => System.get_env("REGION")},   # the REGION RegionNodes uses
  canary: System.get_env("HOTCODE_CANARY") == "true",
  canary_check: {Realtime.HotcodeCanary, :check, []},
  store_dir: "/var/lib/realtime/hotcode",    # a node without one cannot serve the release
  spread: [sample_ms: 10_000, jitter_ms: 5_000]

and build its releases with --rollout-group-by region, so each region is a group: its own cap, regions one after the other, pulls from a node of the same region first.

Things to know for Realtime:

  • Hotcode's scope is its own (:hotcode); it never calls :syn.set_event_handler/1, so Realtime.SynHandler stays in place;
  • the slot locks are :global locks among the nodes of one group (here a region), small groups, so they do not involve the other regions;
  • canary_check can be anything that says the node serves: the share of successful channel joins over the last interval, for example; Hotcode.Health.check/0 is the gate after a pull;
  • gen_rpc is not used by Hotcode: fetches go over Erlang distribution (:erpc), one envelope per node, from a node of the same group (region) when there is one;
  • a node drained for shutdown (DrainingNodes) still runs Hotcode; if it goes away mid-upgrade the others continue without it.

Threat model

What changes is written in Security. In short:

  • the policy is under the signatures: a holder of one key with threshold: 2 cannot add, remove or change it;
  • the table a node decides from is not trusted for what it loads: a node that forges its entry (or serves a forged envelope) can make others try a pull, and each of them verifies what it gets as any deploy. It cannot make a node load anything the signers did not sign for that node's audience, within its expiry, on its base. At most it can make the nodes start a release the signers already approved sooner than the policy says (by claiming to be a spreader), or stop it (by claiming a halt or failures);
  • a push is the same bytes reaching a node by another path: the node accepts it only for the release it would pull right now and verifies it the same way. A forged push is refused and does not even mark the node :failed;
  • a resume is signed like a deploy and bound to one release; a forged entry cannot resume a halt (each node clears its halt only for a resume it verified itself);
  • inside the cluster the Erlang cookie remains the trust boundary, as for a roll: a cookie holder can already :erpc anything.

What is tested, and how

Real nodes (test/cluster_spread_test.exs, one BEAM per node via :peer, :syn in each): canary-only deploys, promotion and require_promote, load while nodes upgrade, groups taking their turn, halts, undo and resume (also racing), partitions, nodes that cannot pull and are pushed to, nodes that forge their entries in the table, a killed node holding a slot, and a release that requires another. Unit tests (test/spread_plan_test.exs, test/spread_policy_test.exs, test/spread_metadata_test.exs): every branch of the state machine on hand-made tables, the policy's shape, the build flags and the metadata rules.

Simulated (test/spread_sim_test.exs, Hotcode.SpreadSim): 200 nodes in five groups (a "region" metadata value each, group_by: "region") with no BEAM. Every decision is the real Plan.decide/4; what is simulated is the clock, a view that lags 200 ms, the transport (a fetch occupies its source for 200 ms, a deploy takes 2 to 4 s), perfect slot locks, and the loader. Policy: 2 canaries, soak 30 s, success 0.99, fanout 4, max_unavailable_pct 10, group_by "region", halt_failures 3; node tick 500 ms, jitter up to 1 s. Results (seed 1, simulated time):

scenario outcome
200 nodes, group_by_group promoted at 31.5 s, first pull done at 34.5 s, every node at 219 s; at most 4 nodes of a group upgrading at once
100 nodes, group_by_group every node at 216 s (half the nodes per group, half the cap: same number of waves)
200 nodes, order: any every node at 72 s; at most 4 per group; sources answered busy up to 50 times each
4 unhealthy nodes in the second group halted at 79 s with 3 failed and 54 nodes on the release; no pull started after the halt; groups 3 to 5 untouched
the same, with auto_rollback (after_ms 10 min) halted at 79.2 s, undone by one node at 82.5 s (once the pulls already running ended): 0 nodes on the release
200 nodes, every tenth node cannot pull every node at 216.9 s; the 20 that cannot pull were each pushed once (20 pushes, at most 2 by one node); at most 4 per group upgrading
one unhealthy canary halted at its deadline (60 s); no other node pulled

Work per node, 200 nodes, group_by_group: the busiest node served 7 envelopes (17 with any); every pending node fetched once and published 3 entry updates (pending, upgrading, upgraded); a canary published 34 (one per health sample). What does grow with the cluster: each entry update is delivered by :syn to every node (N small messages per update, a handful of updates per node per release), and each node reads the whole table on every tick (O(N) work in memory, no network). The undo, when it runs, is one node taking one :global lock over every reachable node and calling every node that has the release, 8 at a time (undo_concurrency).

What grows with N, counted in the simulation (order: any; the undo from the halt scenario):

nodes entry messages, whole rollout per pending node (3 updates x N-1) reads under slots, whole rollout undo: lock participants / holder calls / rounds of 8
50 10,388 147 480 50 / 13 / 2
100 35,838 297 1,960 100 / 33 / 5
200 131,738 597 7,920 200 / 54 / 7

The entry fan-out is O(N) per node and O(N²) for the rollout, in small messages, a handful of updates per node; the reads under a slot are O(group size) per pull; the undo is one lock round over N nodes and holders/8 rounds of calls, once.

Decisions taken by default

These are choices this implementation made where the design left room; each can be changed.

  • Opt-in twice. The signers' policy and the nodes' mode: :spread. The :syn backend is chosen by configuration (members_backend: :syn), not by detecting :syn, so that adding :syn to an application does not change how its nodes see each other.
  • Pull first, push as the fallback. A node starts its own pull, so a source never holds N outgoing calls. A node that cannot pull asks for a push after push_after_attempts failed pulls (a signed policy field, so the signers bound how soon a node may be pushed to; default 3), or at once with spread: [pull: false]. One designated pusher per node (a hash of its name over its group's sources), one push at a time per pusher, counted against its fanout. The receiving node accepts only what it would pull itself, and a refused push does not make it :failed.
  • Every reachable canary must pass, not only min_canaries: one canary still soaking is never overruled by others passing. min_canaries guards against canaries that went away.
  • halt_failures counts refusals too (an expired envelope, a base mismatch), not only health failures: either way the fleet cannot take the release.
  • Halting is sticky for that release on every node that saw it; a new release starts over.
  • The undo of a halted release starts at once: with rollout and auto_rollback, the halt is the trigger. after_ms keeps its meaning for the deadman (mode: :auto, releases without a rollout policy). A resume is possible only before the undo starts (same lock).
  • A resume retries every failed node once: those refused before loading as they are, those that rolled back after their own health gate through one armed acceptance of exactly that statement (the replay counter is not lowered, and nothing else can arm it).
  • The cap is partition-safe through a majority rule: a node upgrades only when it sees a strict majority of its group's known nodes. A node removed for good stays in the table as :down (as for the deadman's quorum) until the table forgets it at a restart; a group that lost half its known nodes for good stops upgrading until then.
  • The resume's own seq is its replay counter (per release, per node): an old resume cannot be sent again. It is kept in memory; a node that restarts forgets the halt as well.
  • A restarted canary soaks again if nothing was promoted: its earlier samples are gone.
  • done is announced by telemetry on every node that sees it, not published: that would be N more updates to N nodes.
  • Metadata has no built-in keys. Hotcode never reads a region, a zone or anything else from the environment: a node has the labels its configuration gives it, and a policy names the ones it uses. Nodes without the group_by key form one group of their own rather than being refused, so a node that lacks the label still upgrades.
  • hotcode wait adds exit code 6 (the time ran out and the spread is still going): neither "failed" (5) nor "error" (1) says that, and a pipeline needs to tell it apart.

Limits

  • A halt caused by failures in ANOTHER group (with order: any or a cluster-wide count) reaches a node with the table's delay; pulls already under way elsewhere finish (at most the cap of each group). Within a group the re-read under the slot makes it exact.
  • Status and wait show the view of the node asked; during a partition two nodes can disagree.
  • A push goes over Erlang distribution like a pull: a node that no source can reach at all cannot be pushed to either. pull: false covers a node that may not open connections itself.
  • A node's designated pusher is computed from the table; while that pusher is busy or slow, the node waits for it (the next push is backoff_ms later).
  • The retry of a rolled-back statement is armed in memory: a node that restarts between the resume and its retry stays :failed.
  • A node without store_dir keeps no envelope and cannot serve one.