fix(ha-prevote): make PreVote denial log-reason match the eligibility gate order exactly
The cluster.c denial-reason elimination ordered catch_up before fresh_heartbeat, disagreeing with raft_cb_vote_eligible (which checks fresh-heartbeat-on-STANDBY before catch-up). In the rare STANDBY catch-up + fresh-heartbeat overlap the log could report catch_up while the gate denied on fresh_heartbeat. Expose the pure read predicate ha_heartbeat_is_fresh and mirror the gate's exact order so the logged reason can no longer disagree with the actual denial. Decision unchanged; log-string fidelity only. prevote/vote-gate/failover-prevote suites green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c45f80ab2b
commit
47f733891b
3 changed files with 16 additions and 10 deletions
|
|
@ -508,12 +508,12 @@ static int myreq_handler(vtask_t* task)
|
|||
/* Distinguish the denial reason for operator diagnosis
|
||||
* (Req 7.2). raft_on_pre_vote_request denies on (a) stale term
|
||||
* — cand_term < raft.term — or (b) the shared eligibility gate
|
||||
* (raft_cb_vote_eligible): PRIMARY-deny, fresh-heartbeat
|
||||
* stickiness, or catch-up. We re-derive which fired WITHOUT
|
||||
* calling the file-static heartbeat-fresh predicate: when the
|
||||
* role is STANDBY and the node is neither catching up nor at a
|
||||
* stale term, the only remaining eligibility denial is fresh
|
||||
* heartbeat (a stale heartbeat would have passed the gate). */
|
||||
* (raft_cb_vote_eligible). Mirror that gate's exact predicate
|
||||
* ORDER so the logged reason cannot disagree with the actual
|
||||
* denial: stale-term, then PRIMARY, then fresh-heartbeat on a
|
||||
* STANDBY, then catch-up. ha_heartbeat_is_fresh is a pure read
|
||||
* exposed for this purpose, so the fresh-heartbeat-vs-catch-up
|
||||
* overlap is reported exactly as the gate decided it. */
|
||||
uint64_t my_raft_term = c->ha.raft.term;
|
||||
if (cand_term < my_raft_term) {
|
||||
deny_reason = "stale_term";
|
||||
|
|
@ -522,11 +522,12 @@ static int myreq_handler(vtask_t* task)
|
|||
&c->ha.role, memory_order_acquire);
|
||||
if (role == CTRL_PRIMARY)
|
||||
deny_reason = "primary";
|
||||
else if (role == CTRL_STANDBY &&
|
||||
ha_heartbeat_is_fresh(&c->ha))
|
||||
deny_reason = "fresh_heartbeat";
|
||||
else if (atomic_load_explicit(&c->ha.in_catch_up,
|
||||
memory_order_acquire))
|
||||
deny_reason = "catch_up";
|
||||
else if (role == CTRL_STANDBY)
|
||||
deny_reason = "fresh_heartbeat";
|
||||
else
|
||||
deny_reason = "eligibility";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue