chore: checkpoint all prior work for clean state
Captures all uncommitted work from ha-config-bootstrap, ha-heartbeat-liveness, and associated spec/tooling updates: - src: ha.c, ha.h, cluster.c, config_repl.c, myapp.c, raft.c — heartbeat liveness, RDHUP integration, committing phase fixes - tests: test_ha_role.c, test_config_repl.c, test_ha_rdhup_integration.c, test_p1_integration.c, test_p3_hardening.c, scheduler test - specs: election-iomgr-refactor, ha-heartbeat-liveness, ha-peer-connection-reuse, raft-library (new); ha-config-bootstrap and election-iomgr-refactor task/research updates - tooling: .wolf/ state, ha/data cluster fixtures, raft/raft.tla, src/build symlink, xce-build skill update
This commit is contained in:
parent
15bd291bdd
commit
e31673dd88
66 changed files with 122422 additions and 860 deletions
|
|
@ -131,14 +131,7 @@ typedef struct {
|
|||
uint32_t committing_timeout_ms; /* Quorum-ACK deadline for CTRL_PRIMARY_COMMITTING (default 10000) */
|
||||
} ha_config_t;
|
||||
|
||||
typedef struct {
|
||||
xce_candidate_t *candidate; /* peer to probe */
|
||||
void *ssl_ctx; /* SSL_CTX* (void* to avoid openssl header) */
|
||||
uint32_t timeout_ms;
|
||||
atomic_int *election_done;
|
||||
int got_ack;
|
||||
pthread_t thread;
|
||||
} probe_ctx_t;
|
||||
/* probe_ctx_t deleted — only used by am_i_primary() (election-iomgr-refactor) */
|
||||
|
||||
/* ── HA runtime state (embedded in cluster_t as `ha_state_t ha` in P1-5) ── */
|
||||
typedef struct {
|
||||
|
|
@ -152,14 +145,12 @@ typedef struct {
|
|||
_Atomic int promotion_failed;
|
||||
_Atomic int promotion_retry_count;
|
||||
_Atomic int in_catch_up; /* Non-zero while processing historical WAL entries */
|
||||
_Atomic int failover_requested; /* Set by SIGUSR1 handler; watchdog executes */
|
||||
/* failover_requested deleted — watchdog replaced by ha_arm_heartbeat_timeout_vtask */
|
||||
int hooks_registered; /* Idempotency guard for xce_add_hook calls */
|
||||
uint32_t last_received_crc; /* Chained CRC of last received replicated entry */
|
||||
ha_config_t config;
|
||||
pthread_mutex_t lock; /* Protects primary_host/port + last_heartbeat */
|
||||
/* Watchdog thread — started in P1-3 */
|
||||
_Atomic int watchdog_stop;
|
||||
pthread_t watchdog_thread;
|
||||
/* watchdog_stop / watchdog_thread deleted — replaced by ha_arm_heartbeat_timeout_vtask */
|
||||
void *ssl_ctx; /* SSL_CTX* cast; avoids pulling openssl headers here */
|
||||
uint64_t jitter_seed; /* xorshift64 PRNG state for election jitter */
|
||||
zarray_t *standby_endpoints; /* connected standby controller endpoints for config push */
|
||||
|
|
@ -183,6 +174,7 @@ typedef struct {
|
|||
/* ── New fields added by raft-library spec (Task 6.2) ──────── */
|
||||
cluster_t *raft_c; /* cluster_t* set by ha_start_election_async; used by raft callbacks */
|
||||
void *raft_election_timeout_ctx; /* election_timeout_ctx_t* for cancel (task 6.2) */
|
||||
void *committing_timeout_ctx; /* committing_timeout_ctx_t* for cancel on step-down */
|
||||
/* ── New fields added by ha-heartbeat-liveness spec (Task 1.1) ── */
|
||||
time_t last_activity; /* CLOCK_MONOTONIC seconds of last primary message; 0 = none yet */
|
||||
} ha_state_t;
|
||||
|
|
@ -201,11 +193,7 @@ int ha_init(ha_state_t *ha, const ha_config_t *cfg, int my_priority);
|
|||
*/
|
||||
void ha_fini(ha_state_t *ha);
|
||||
|
||||
/*
|
||||
* am_i_primary: stub — priority-0 node is primary.
|
||||
* Full election probing added in P1-3.
|
||||
*/
|
||||
int am_i_primary(cluster_t *c);
|
||||
/* am_i_primary() deleted — replaced by ha_start_election_async (election-iomgr-refactor) */
|
||||
|
||||
/*
|
||||
* ha_promote_to_primary: stub — atomically sets role to PRIMARY.
|
||||
|
|
@ -234,35 +222,6 @@ void ha_do_promote(ha_state_t *ha);
|
|||
*/
|
||||
void ha_do_demote(ha_state_t *ha);
|
||||
|
||||
/*
|
||||
* ha_install_sigusr1: register a SIGUSR1 handler that atomically sets
|
||||
* ha->failover_requested. The handler uses only async-signal-safe operations
|
||||
* (atomic store on an int-width type — POSIX.1-2017 §2.4.3).
|
||||
* Must be called once, before any signal can arrive.
|
||||
*/
|
||||
void ha_install_sigusr1(ha_state_t *ha);
|
||||
|
||||
/* ── Watchdog thread API (P1-3) ────────────────────────────── */
|
||||
|
||||
/*
|
||||
* ha_start_watchdog: spawn the heartbeat watchdog pthread.
|
||||
* Must be called after ha_init(). Returns 0 on success, -errno on failure.
|
||||
*/
|
||||
int ha_start_watchdog(ha_state_t *ha);
|
||||
|
||||
/*
|
||||
* ha_stop_watchdog: set watchdog_stop flag and pthread_join the thread.
|
||||
* Safe to call if watchdog was never started (thread == 0).
|
||||
*/
|
||||
void ha_stop_watchdog(ha_state_t *ha);
|
||||
|
||||
/*
|
||||
* ha_check_heartbeat_nocluster: test-only entry point — logic is inlined in
|
||||
* ha_watchdog_thread() in production. Only compiled under XCE_TESTING.
|
||||
*/
|
||||
#ifdef XCE_TESTING
|
||||
void ha_check_heartbeat_nocluster(ha_state_t *ha);
|
||||
#endif
|
||||
|
||||
/* ── Redirect helpers used by join.c ──────────────────────── */
|
||||
|
||||
|
|
@ -289,18 +248,7 @@ int ha_is_primary(const ha_state_t *ha);
|
|||
|
||||
/* ha_check_priority_stepdown() deleted — replaced by quorum election (Req 2.1) */
|
||||
|
||||
/*
|
||||
* start_heartbeat_listener: start a minimal pre-Phase-2 SSL listener
|
||||
* that responds to OP_heartbeat probes. Called after am_i_primary()
|
||||
* returns 1. Records tid in c->heartbeat_listener_tid.
|
||||
*/
|
||||
void start_heartbeat_listener(cluster_t *c);
|
||||
|
||||
/*
|
||||
* stop_heartbeat_listener: signal and join the heartbeat listener thread.
|
||||
* Must be called before iomgr_init() to free the listening port (EADDRINUSE).
|
||||
*/
|
||||
void stop_heartbeat_listener(cluster_t *c);
|
||||
/* start_heartbeat_listener() / stop_heartbeat_listener() deleted — never called (election-iomgr-refactor) */
|
||||
|
||||
/*
|
||||
* ha_dispatch_gate: role-based operation filter for the vtaskmgr dispatch loop.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue