From e5f0c4728e257828ce5b0bc91b46b6929ac428e1 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 15 Nov 2026 12:42:50 -0800 Subject: [PATCH] master: re-probe only on a ready AND placeable newer current fact Review of #130 r5 (one P2): the recovery re-probe triggered on the newer heartbeat's ReadyForPrimary bit alone. A newer engine-ready but ineligible, withdrawn or unreachable heartbeat, with the frontend now ready, led to a re-probe that returned the current primary ready, so the gate skipped its placeability check and preserved an excluded primary. The trigger is now the whole fresh verdict: the newer fact must be ready and placeable (reachable, eligible, not withdrawn). An excluded newer fact causes no re-probe, so the first verdict and the gate's fresh placeability/grace check decide, and the failover stands. Refs #128 Co-Authored-By: Claude Opus 5.5 --- seaweed-block/core/host/master/product_loop.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/seaweed-block/core/host/master/product_loop.go b/seaweed-block/core/host/master/product_loop.go index f0aa9d12c7..9f8ad00153 100644 --- a/seaweed-block/core/host/master/product_loop.go +++ b/seaweed-block/core/host/master/product_loop.go @@ -482,9 +482,13 @@ func (h *Host) probePromotionCandidates(volumeID string, current authority.Autho // 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. +// more and that fresh result is used. The trigger is the whole fresh +// verdict, never the single ReadyForPrimary bit: the newer fact must be +// ready AND placeable (reachable, eligible, not withdrawn), so frontend +// readiness can never preserve a primary the newest fact excludes. A +// heartbeat alone is never taken as frontend readiness either: 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) @@ -492,7 +496,7 @@ func (h *Host) probePromotionCandidatesCurrent(volumeID string, current authorit return result, ok } after, afterOK := h.freshCurrentSlot(volumeID, current.ReplicaID) - if !afterOK || !after.ReadyForPrimary { + if !afterOK || !after.ReadyForPrimary || !after.Reachable || !after.Eligible || after.Withdrawn { return result, ok } if beforeOK && !after.ObservedAt.After(before.ObservedAt) && after.Incarnation == before.Incarnation {