From 43ccf9456e4e27d74d97d9b2342f98790c03bdae Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 25 Nov 2026 17:12:18 -0800 Subject: [PATCH] fix(master): manual failover of an unreachable primary runs the fencing round at every replica count An operator failover whose primary has no fresh, reachable heartbeat (a lost host) is no planned move from a live primary: it is now decided on the fencing round for RF2 as for RF3 (one path, basis Fenced). A failover from a reachable RF2 primary stays planned; best_effort stays refused. Co-Authored-By: Claude Opus 5.5 --- .../core/host/master/planned_move.go | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/seaweed-block/core/host/master/planned_move.go b/seaweed-block/core/host/master/planned_move.go index 6a270f6604..647ce0739a 100644 --- a/seaweed-block/core/host/master/planned_move.go +++ b/seaweed-block/core/host/master/planned_move.go @@ -79,6 +79,12 @@ func (h *Host) plannedMoveEvidence(volumeID, target string) (adapter.PrimaryEvid } return adapter.PrimaryEvidence{}, err } + // The primary is unreachable (a lost host stops heartbeating): the move + // is the operator's failover, not a planned move from a live primary, and + // it is decided on the fencing round at every replica count. + if h.primaryUnreachable(volumeID) { + return h.fencedMoveEvidence(volumeID, target, profile, placement.Slots) + } result, err := prober.ProbePromotionCandidates(volumeID, authority.AuthorityBasis{}, []authority.ReplicaCandidate{{ReplicaID: target, ServerID: targetServer}}) if err != nil { return adapter.PrimaryEvidence{}, fmt.Errorf("planned move: probe round: %w", err) @@ -93,8 +99,20 @@ func (h *Host) plannedMoveEvidence(volumeID, target string) (adapter.PrimaryEvid return adapter.PrimaryEvidence{}, fmt.Errorf("planned move: replica %s did not answer the probe round ready (caught up, epoch table valid)", target) } +// primaryUnreachable: the line's primary has no fresh, reachable heartbeat +// slot. A volume without a line has no primary to lose. +func (h *Host) primaryUnreachable(volumeID string) bool { + current, ok := h.Publisher().VolumeAuthorityLine(volumeID) + if !ok { + return false + } + slot, fresh := h.freshCurrentSlot(volumeID, current.ReplicaID) + return !fresh || !slot.Reachable +} + // fencedMoveEvidence is the operator's move where a planned move needs a seal -// (the target is not in every acknowledgement set: RF3 sync_quorum). The +// (the target is not in every acknowledgement set: RF3 sync_quorum), or +// whose primary is unreachable (the operator's failover, any count). The // fencing round is that seal: every other replica is fenced at the line's // next epoch, so the old primary, dead or alive, can no longer collect an // acknowledgement, and the decision is read from the round alone