feat(election-iomgr-refactor): COMMITTING path in ha_elect_evaluate_and_signal + committing/election timeout watchdogs — tasks 4.1, 4.3, 4.4
This commit is contained in:
parent
6de4b3ff0e
commit
f4a6726f1b
6 changed files with 646 additions and 65 deletions
|
|
@ -96,6 +96,10 @@ typedef struct {
|
|||
* (quorum-reached path) can set timeout_ctx->cancelled = 1 to cancel the
|
||||
* watchdog. Set by ha_start_election_async after scheduling the timeout. */
|
||||
void *timeout_ctx; /* election_timeout_ctx_t*; NULL until watchdog scheduled */
|
||||
/* Task 4.1: cluster_t* so ha_elect_evaluate_and_signal can call
|
||||
* cluster_init_phase2(c) and arm the committing timeout watchdog.
|
||||
* NULL in unit tests (c=NULL bypasses phase2 and watchdog arming). */
|
||||
cluster_t *c;
|
||||
ha_vote_entry_t votes[]; /* C99 flexible array: n_peers-1 entries */
|
||||
} ha_elect_ctx_t;
|
||||
|
||||
|
|
@ -496,9 +500,24 @@ int ha_find_and_connect_to_primary(ha_state_t *ha,
|
|||
#define HA_FIND_PRIMARY_T3_INIT_MS 100
|
||||
#define HA_FIND_PRIMARY_T3_MAX_MS 5000
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
/* ── P3-6: Test-only failover shim ────────────────────────────── */
|
||||
|
||||
#ifdef XCE_TESTING
|
||||
/*
|
||||
* ha_phase2_hook: test-only seam for cluster_init_phase2.
|
||||
* When non-NULL, ha_elect_evaluate_and_signal() calls this INSTEAD OF the
|
||||
* real cluster_init_phase2() so unit tests can count phase2 calls without
|
||||
* requiring a real cluster_t. Pattern mirrors xce_vote_request_hook.
|
||||
*/
|
||||
extern int (*ha_phase2_hook)(void *c);
|
||||
|
||||
/* Test-only shim: demote then re-promote; returns new term.
|
||||
* Exercises the manual failover state machine without a live cluster_t.
|
||||
* Calls ha_do_demote() then ha_do_promote(); validates role transitions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue