feat(ha-config-bootstrap): implement repl_wait_majority_ack with quorum formula and ack_op discrimination (task 7.3)

This commit is contained in:
Rongsong Shen 2026-05-28 13:57:24 +00:00
parent 3969064e11
commit 30bcb74a67
3 changed files with 125 additions and 12 deletions

View file

@ -20,9 +20,10 @@ typedef void* repl_ep_t;
/* Per-standby connection slot */
typedef struct {
repl_ep_t ep; /* NULL = slot empty */
_Atomic uint64_t acked_lsn; /* Last LSN ACKed by this standby */
_Atomic int in_catch_up; /* Non-zero while catching up */
repl_ep_t ep; /* NULL = slot empty */
_Atomic uint64_t acked_lsn; /* Last WAL LSN ACKed (walAck) */
_Atomic uint64_t acked_config_lsn; /* Last config LSN ACKed (upgradeConfigAck) */
_Atomic int in_catch_up; /* Non-zero while catching up */
uint64_t join_applied_lsn; /* LSN standby reported on reconnect */
char host[XCE_MAXNAME_LEN];
uint32_t port;
@ -54,13 +55,16 @@ void repl_expire_disconnect_slots(replicator_t *r, time_t now_s, uint32_t snap_i
int repl_broadcast(replicator_t *r, const wal_entry_hdr_t *hdr,
const void *payload, uint32_t payload_len);
/* ACK handling — call from io_worker read callback ONLY */
/* WAL ACK handling — call from io_worker read callback ONLY */
void repl_on_ack(replicator_t *r, repl_ep_t ep, uint64_t acked_lsn);
/* Config ACK handling — call from io_worker read callback ONLY (task 8.1) */
void repl_on_config_ack(replicator_t *r, repl_ep_t ep, uint64_t acked_config_lsn);
/* Sync replication (stub in P2-1; wired in P2-3) */
int repl_wait_ack(replicator_t *r, uint64_t target_lsn, uint32_t timeout_ms);
/* Majority-quorum ACK wait — stub until task 7.3 */
/* Majority-quorum ACK wait (task 7.3) */
int repl_wait_majority_ack(replicator_t *r, uint32_t timeout_ms, uint8_t ack_op);
/* WAL trim guard */