feat(ha-single-leader-role): delete force-promotion watchdog + convergence/ack machinery (task 4.1)

This commit is contained in:
Rongsong Shen 2026-06-13 12:05:08 +00:00
parent b7b951b9e7
commit a5bf86112a
10 changed files with 95 additions and 1869 deletions

View file

@ -397,26 +397,6 @@ void ha_process_standby_state(ha_state_t *ha, int peer_idx,
uint64_t reported_tag, uint64_t reported_lsn,
uint64_t committed_tag, uint64_t committed_lsn);
/* ── Task 5.2: Majority-convergence → PRIMARY transition ─────────────────────
*
* 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 - 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.
* Logs INFO "majority converged (N/M standbys) → CTRL_PRIMARY" (Req 7.4).
* If c != NULL, registers persistence hooks and arms periodic heartbeat.
*
* Called from repl_ack_decode_and_dispatch after ha_process_standby_state.
*
* Requirements: 2.3, 2.4, 6.3, 6.5 (ha-repl-hardening spec)
* Boundary: Controller FSM (ha.c)
*/
void ha_check_majority_convergence(ha_state_t *ha, cluster_t *c);
/* ── Task 3.5c: Standby snapshot receive handler ──────────────────────────── */
/*
@ -628,13 +608,6 @@ void ha_start_election_async(ha_state_t *ha, cluster_t *c,
uint64_t my_config_tag, uint64_t my_lsn,
const char *my_name);
/*
* ha_repl_ack_received: called when a standby ACKs config+WAL catch-up
* (OPCode_replCatchUpDone). Increments repl_ack_count; when majority
* threshold is reached, calls ha_promote_to_primary (Req 8.2).
*/
void ha_repl_ack_received(ha_state_t *ha, cluster_t *c);
/*
* ha_dispatch_repl_action_for_standby: evaluate the replication decision for
* one standby and execute the resulting action.
@ -793,8 +766,9 @@ extern void (*ha_rdhup_election_hook)(ha_state_t *ha, cluster_t *c,
/*
* vote_ep_ctx_set_cluster_for_test: set the cluster_t pointer inside the
* vote_ep_ctx_t stored at ep->data. Used by unit tests that need
* ha_repl_ack_received to call ha_promote_to_primary(c) when quorum is reached.
* vote_ep_ctx_t stored at ep->data. Used by unit tests that need the
* promoted-endpoint dispatch path to reach ha_promote_to_primary(c) with a
* live cluster pointer.
* The vote_ep_ctx_t struct is internal to ha.c; this helper avoids exposing it.
* Requirements: task 7.3 (ha-peer-connection-reuse).
*/