master: re-probe when the current primary reports ready during the promotion probe

Review of #130 r4 (one P2): the production provider probes the current
primary first, then the peers. If the current primary's frontend
finished recovery and a newer ready heartbeat arrived during the peer
queries, both gates ended its grace but still direct-reassigned from the
probe's outdated Current.Ready=false.

Both gates now go through probePromotionCandidatesCurrent: when the
current primary's own fresh heartbeat advanced to ready (a newer fact or
a new incarnation) while the probe ran and the probe said it was not
ready, the probe is run once more and that fresh result decides. A
heartbeat is never taken as frontend readiness: if the fresh probe still
finds the frontend unready, the failover stands; a heartbeat already
ready before the probe causes no re-probe.

Refs #128

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-15 12:27:43 -08:00
1 parent b2e79c8457
commit 6989dfd838
1 file changed
+28 -2
+28 -2
View File
@@ -160,7 +160,7 @@ func (h *Host) applyPromotionEvidenceGate(snap *authority.ClusterSnapshot) (int,
continue continue
} }
probeCount++ probeCount++
result, ok := h.probePromotionCandidates(vol.VolumeID, vol.Authority, candidates) result, ok := h.probePromotionCandidatesCurrent(vol.VolumeID, vol.Authority, candidates)
allowed := promotionAllowedReplicas(result, ok) allowed := promotionAllowedReplicas(result, ok)
if ok { if ok {
h.log.Printf("blockmaster: promotion gate volume=%s current=%s current_known=%t current_ready=%t ack_profile=%s required_lsn=%d candidates=%v allowed=%v", h.log.Printf("blockmaster: promotion gate volume=%s current=%s current_known=%t current_ready=%t ack_profile=%s required_lsn=%d candidates=%v allowed=%v",
@@ -253,7 +253,7 @@ func (h *Host) applyUnsupportedPromotionEvidenceGate(placements []lifecycle.Plac
} }
} }
probeCount++ probeCount++
result, probeOK := h.probePromotionCandidates(vol.VolumeID, current, candidates) result, probeOK := h.probePromotionCandidatesCurrent(vol.VolumeID, current, candidates)
allowed := promotionAllowedReplicas(result, probeOK) allowed := promotionAllowedReplicas(result, probeOK)
if probeOK { if probeOK {
h.log.Printf("blockmaster: promotion gate unsupported volume=%s current=%s reasons=%v current_known=%t current_ready=%t ack_profile=%s required_lsn=%d candidates=%v allowed=%v", h.log.Printf("blockmaster: promotion gate unsupported volume=%s current=%s reasons=%v current_known=%t current_ready=%t ack_profile=%s required_lsn=%d candidates=%v allowed=%v",
@@ -476,6 +476,32 @@ func (h *Host) probePromotionCandidates(volumeID string, current authority.Autho
return result, true return result, true
} }
// probePromotionCandidatesCurrent probes like probePromotionCandidates,
// but does not let an outdated verdict on the current primary stand
// (#128). The provider probes the current primary before the peers; if
// the current primary's own fresh heartbeat advanced to ready (a newer
// fact, or a new incarnation) while the probe ran, its "not ready"
// verdict may predate a finished recovery, so the probe is run once
// more and that fresh result is used. A heartbeat alone is never taken
// as frontend readiness: the fresh probe still decides, so a frontend
// that is still unready keeps a legitimate failover.
func (h *Host) probePromotionCandidatesCurrent(volumeID string, current authority.AuthorityBasis, candidates []authority.ReplicaCandidate) (PromotionProbeResult, bool) {
before, beforeOK := h.freshCurrentSlot(volumeID, current.ReplicaID)
result, ok := h.probePromotionCandidates(volumeID, current, candidates)
if !ok || (result.CurrentKnown && result.Current.Ready) {
return result, ok
}
after, afterOK := h.freshCurrentSlot(volumeID, current.ReplicaID)
if !afterOK || !after.ReadyForPrimary {
return result, ok
}
if beforeOK && !after.ObservedAt.After(before.ObservedAt) && after.Incarnation == before.Incarnation {
return result, ok
}
h.log.Printf("blockmaster: promotion gate volume=%s current=%s reported ready during the probe; probing again", volumeID, current.ReplicaID)
return h.probePromotionCandidates(volumeID, current, candidates)
}
func promotionAllowedReplicas(result PromotionProbeResult, ok bool) map[string]bool { func promotionAllowedReplicas(result PromotionProbeResult, ok bool) map[string]bool {
allowed := map[string]bool{} allowed := map[string]bool{}
if !ok || !isKnownAckProfile(result.AckProfile) { if !ok || !isKnownAckProfile(result.AckProfile) {