SelfElectionPolicy
Это содержимое пока не доступно на вашем языке.
SelfElectionPolicy =
"immediate"|"never"|number
Defined in: src/cluster/ClusterOptions.ts:103
Whether — and when — this node may declare itself the first member of a
new cluster, moving straight from joining to up with nobody’s
agreement.
'immediate'(default) — self-elect at once iff the seed list is empty. The historical behaviour, and the one that makes single-node development and the “first node has no seeds” convention work.'never'— never self-elect. This node staysjoininguntil a peer’s leader promotes it. Correct for every node that a bootstrap election did not pick: an isolated node then fails to start rather than quietly becoming a cluster of one.- a number of ms — self-elect only after that long without a peer having promoted this node, regardless of whether the seed list is empty. This is the policy the stable-observation bootstrap hands the node it elected as initial seed (#148).
The delay is what makes an address-ordered election safe against an existing cluster. A node that wins the election because its address sorts first may still be joining a cluster that is already running — a scale-up or a rolling restart puts new addresses at arbitrary positions in the order. Because the elected node contacts its seeds like everyone else and only self-elects if that produced nothing, an existing cluster promotes it long before the deadline and no rival cluster is ever formed. Self-electing immediately on winning the election, as the naive reading of “lowest address becomes the seed” suggests, would create exactly the split-brain the election exists to prevent.
