fix(ha-config-bootstrap,ha-repl-hardening): config-less node must not win election
Root cause (found via ha-convergence-recovery task 8 live 3-node E2E): a controller with no local config (config_version_tag==0) could become PRIMARY and push an empty config, breaking replication. Two upstream election-safety gaps, both outside ha-convergence-recovery: 1. RDHUP re-election bypassed the no-config 'voter only' guard. The startup path (ha_start_election_async) refuses to start an election when my_config_tag==0 && n_peers>1, but the RDHUP failover path (ha_on_primary_ctrl_fd_rdhup) called raft_on_leader_lost unconditionally. Fix: mirror the guard before elect_ctx alloc / hook / raft_on_leader_lost; a config-less node stays CTRL_STANDBY (voter only) and grants the configured peer instead of starting (and winning) its own election. 2. Voter freshness gate compared the candidate only against the voter's LOCAL config, ignoring the cluster's known committed state. Fix: ha_vote_self_freshness floors the comparison at max(local, learned-committed config_tag / committed_lsn), so a voter denies any candidate whose config/cluster state is outdated vs what the cluster has committed. Strictly additive (never denies the freshest node — Leader Completeness preserves liveness). TDD: test_rdhup_noconfig_node_does_not_elect + configured-node contrast; test_ha_vote_gate learned-floor deny + liveness + backward-compat. Full controller suite green under ASAN. commit.c and ha-convergence-recovery files untouched.
This commit is contained in:
parent
513b965f98
commit
c97c7632e9
6 changed files with 439 additions and 9 deletions
|
|
@ -291,6 +291,14 @@ static void test_rdhup_calls_start_election_async(void)
|
|||
myconf_t myconf;
|
||||
memset(&myconf, 0, sizeof(myconf));
|
||||
myconf.name = "ctrl-a";
|
||||
/* Configured node: a real (nonzero) config tag so the no-config voter-only
|
||||
* RDHUP guard does NOT trip — this test exercises the legitimate "a
|
||||
* CONFIGURED node re-elects after RDHUP" path (ha-config-bootstrap Req 2.8).
|
||||
* Without a tag, config_version_tag==0 with candidates_count>1 would (post
|
||||
* election-safety fix) keep the node a passive voter (CTRL_STANDBY) and the
|
||||
* election hook would never fire — that was the buggy condition this test
|
||||
* incidentally relied on. */
|
||||
myconf.config_version_tag = 0x1234;
|
||||
myconf.peers_cfg.candidates_count = 2;
|
||||
snprintf(myconf.peers_cfg.candidates[0].name,
|
||||
sizeof(myconf.peers_cfg.candidates[0].name), "ctrl-a");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue