refactor(ha-repl-hardening): standardize n_peers = total cluster size including self
- ha_state_t.n_peers now matches raft_config_t.n_peers convention: total cluster size (including self), consistently across both layers - ha_start_election_async: ha->n_peers = n_peers (candidates_count) - Convergence/counting loops: i < n_peers - 1 (skip self for standby arrays) - Single-node: n_peers=1, threshold=0 (same behavior, clear semantics) - ha_elect_ctx_t.n_peers unchanged (separate field for vote array sizing) - Tests: 3-node n_peers=2->3, single-node 0->1, loop bounds updated E2E test 6.7: 3-node cluster lifecycle verified - Initial: ctrl-1 PRIMARY via majority convergence, no degraded mode - Kill primary: RDHUP detected on both standbys, ctrl-2 elected at term=4 - No data loss: config tag preserved across failover - Full ASAN build green
This commit is contained in:
parent
361397ac02
commit
f236d320a2
4 changed files with 71 additions and 31 deletions
|
|
@ -176,7 +176,7 @@ typedef struct {
|
|||
void *client_ssl_ctx; /* SSL_CTX* (TLS_client_method); created in myapp_run */
|
||||
int phase2_done; /* 1 after cluster_init_phase2 runs */
|
||||
_Atomic int repl_ack_count; /* count of standbys that ACKed in COMMITTING state */
|
||||
int n_peers; /* total candidate count (excluding self) */
|
||||
int n_peers; /* total cluster size (including self), matches raft convention */
|
||||
/* ── New fields added by raft-library spec (Task 6.1) ──────── */
|
||||
raft_state_t raft; /* Raft consensus state (wired in task 6.2) */
|
||||
/* ── New fields added by raft-library spec (Task 6.2) ──────── */
|
||||
|
|
@ -389,8 +389,8 @@ void ha_process_standby_state(ha_state_t *ha, int peer_idx,
|
|||
* ha_check_majority_convergence: count converged standbys and promote to
|
||||
* CTRL_PRIMARY when the threshold is met while role == CTRL_PRIMARY_COMMITTING.
|
||||
*
|
||||
* Threshold: ha->n_peers (all standbys must converge).
|
||||
* Single-node (n_peers=0): threshold=0 → satisfied immediately.
|
||||
* Threshold: ha->n_peers - 1 (all standbys must converge).
|
||||
* Single-node (n_peers=1): threshold=0 → satisfied immediately.
|
||||
*
|
||||
* Double-promotion is prevented by the single-threaded vtask context; a role
|
||||
* check (CTRL_PRIMARY_COMMITTING) is sufficient.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue