From 183aee800cfecda5dcc761722f5242262adce00b Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 5 Dec 2026 15:13:28 -0800 Subject: [PATCH] seaweed-block: a controller Reassign names the line it was decided against The rebalance and failover asks carry ExpectCurrent, as the controller's endpoint refresh already does, so the publisher refuses one whose line moved while it waited in the queue. A refused ask ends without a publication and the next intake decides again against the new line. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/core/authority/controller.go | 39 +++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/seaweed-block/core/authority/controller.go b/seaweed-block/core/authority/controller.go index 2318ee74f4..e3fb480786 100644 --- a/seaweed-block/core/authority/controller.go +++ b/seaweed-block/core/authority/controller.go @@ -566,13 +566,14 @@ func (c *TopologyController) decideVolume( return AssignmentAsk{}, "the current primary is acceptable; rebalance target " + target.ReplicaID + " has no planned-move evidence", false } return AssignmentAsk{ - VolumeID: vol.VolumeID, - ReplicaID: target.ReplicaID, - DataAddr: target.DataAddr, - CtrlAddr: target.CtrlAddr, - Intent: IntentReassign, - Evidence: plannedEvidence(target.PromotionEvidence), - Incarnation: target.Incarnation, + VolumeID: vol.VolumeID, + ReplicaID: target.ReplicaID, + DataAddr: target.DataAddr, + CtrlAddr: target.CtrlAddr, + Intent: IntentReassign, + Evidence: plannedEvidence(target.PromotionEvidence), + Incarnation: target.Incarnation, + ExpectCurrent: expectedLineOf(currentLine), }, "rebalance", true } return AssignmentAsk{}, "the current primary is acceptable", false @@ -599,13 +600,14 @@ func (c *TopologyController) decideVolume( // its target (one decider): no evidence, no promotion. if best.PromotionEvidence.Kind == adapter.PrimaryKindPromotion { return AssignmentAsk{ - VolumeID: vol.VolumeID, - ReplicaID: best.ReplicaID, - DataAddr: best.DataAddr, - CtrlAddr: best.CtrlAddr, - Intent: IntentReassign, - Evidence: best.PromotionEvidence, - Incarnation: best.Incarnation, + VolumeID: vol.VolumeID, + ReplicaID: best.ReplicaID, + DataAddr: best.DataAddr, + CtrlAddr: best.CtrlAddr, + Intent: IntentReassign, + Evidence: best.PromotionEvidence, + Incarnation: best.Incarnation, + ExpectCurrent: expectedLineOf(currentLine), }, "failover", true } why = "failover target " + best.ReplicaID + " has no promotion evidence" @@ -639,10 +641,17 @@ func refreshAsk(volumeID string, current ReplicaCandidate, line AuthorityBasis) CtrlAddr: current.CtrlAddr, Intent: IntentRefreshEndpoint, Incarnation: current.Incarnation, - ExpectCurrent: &ExpectedLine{ReplicaID: line.ReplicaID, Epoch: line.Epoch, DataAddr: line.DataAddr, CtrlAddr: line.CtrlAddr}, + ExpectCurrent: expectedLineOf(line), } } +// expectedLineOf conditions an ask on the line it was decided against: a +// publication that lands while the ask waits in the queue (an operator's +// failback) refuses it instead of being overwritten. +func expectedLineOf(line AuthorityBasis) *ExpectedLine { + return &ExpectedLine{ReplicaID: line.ReplicaID, Epoch: line.Epoch, DataAddr: line.DataAddr, CtrlAddr: line.CtrlAddr} +} + func volumeIncludesReplica(vol VolumeTopologySnapshot, replicaID string) bool { for _, slot := range vol.Slots { if slot.ReplicaID == replicaID {