feat(ha-convergence-recovery): quorum transition logging — CAS edge-detect + 4 call sites (task 5.2)
This commit is contained in:
parent
3218d9ffaf
commit
07de4581b0
3 changed files with 84 additions and 12 deletions
|
|
@ -561,6 +561,11 @@ static void raft_cb_become_leader(void *ctx, uint64_t term)
|
|||
}
|
||||
}
|
||||
|
||||
/* Quorum-transition observability (Req 8.1, 8.2): promotion registered the
|
||||
* surviving vote endpoints as standbys — the write-quorum count just changed.
|
||||
* Record any loss/restore edge once (no-op when quorum is held at promotion). */
|
||||
ha_log_quorum_transition(ha);
|
||||
|
||||
if (c) {
|
||||
/* Push config to standbys — read raw bytes from disk so standbys
|
||||
* can save the file. NULL bytes are passed only in test mode. */
|
||||
|
|
@ -1509,6 +1514,11 @@ int ha_dispatch_gate(ha_state_t *ha, int opcode)
|
|||
* are durable across failover. Read-only queries and replication
|
||||
* ops are always allowed. */
|
||||
if (!ha_has_write_quorum(ha)) {
|
||||
/* Quorum-transition observability backstop (Req 8.1, 8.3): record the
|
||||
* loss edge if a membership-change site missed it. The edge detector
|
||||
* makes this silent on every call after the first — repeated rejected
|
||||
* operations do NOT produce a log storm. */
|
||||
ha_log_quorum_transition(ha);
|
||||
switch (opcode) {
|
||||
/* Replication ops — always allowed (they build majority) */
|
||||
case OPCode_heartbeat:
|
||||
|
|
@ -3163,6 +3173,11 @@ static int vote_ep_err_handler(void *ep_raw)
|
|||
* vctx->c may be NULL in test mode — guard accordingly. */
|
||||
if (vctx->c)
|
||||
repl_remove_standby(&vctx->c->persist.repl, ep);
|
||||
|
||||
/* Quorum-transition observability (Req 8.1): a standby just dropped — the
|
||||
* write-quorum count changed. Record the loss edge once (silent if
|
||||
* quorum is still held after the removal). */
|
||||
ha_log_quorum_transition(ha);
|
||||
} else {
|
||||
/* Election phase: count as denied vote */
|
||||
handle_request_vote_reply(ha, vctx->ctx, vctx->peer_idx,
|
||||
|
|
@ -3819,6 +3834,11 @@ static void on_standby_connected(endpoint_t *ep)
|
|||
sctx->peer_idx, rc);
|
||||
}
|
||||
|
||||
/* Quorum-transition observability (Req 8.2): a late-joiner standby connected —
|
||||
* the write-quorum count changed. Record the restore edge once (silent if
|
||||
* quorum was already held). */
|
||||
ha_log_quorum_transition(ha);
|
||||
|
||||
/* Set state-aware dispatcher for subsequent messages on this endpoint */
|
||||
ep->msg_handler = peer_ctrl_msg_handler;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue