seaweed-block: red: an ask published during the intake is enqueued again

The publisher can publish the desired ask and come back for its next one
between the line read an intake decides against and that intake's same-ask
dedupe. The queue then holds nothing for the volume, so the dedupe reads
the ask as lost and enqueues it again; a planned move carries no fence, so
the publisher would mint it a second time at a new epoch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-05 01:29:50 -08:00
1 parent 205e40cf54
commit d975b7a874
1 file changed
+65
@@ -124,3 +124,68 @@ func TestARepeatedlyLostReassignKeepsItsDesiredAtAndBecomesStuck(t *testing.T) {
t.Fatalf("stuck evidence %+v, want the first desire (%v) of Reassign r2", ev, first)
}
}
// publishOnRead runs publish once, right after the controller's skip+1-th
// line read: the publisher applies its ask between the read an intake decides
// against and that intake's dedupe.
type publishOnRead struct {
*fakeBasisReader
skip int
publish func()
}
func (r *publishOnRead) VolumeAuthorityLine(volumeID string) (AuthorityBasis, bool) {
line, ok := r.fakeBasisReader.VolumeAuthorityLine(volumeID)
if r.publish != nil {
if r.skip > 0 {
r.skip--
} else {
p := r.publish
r.publish = nil
p()
}
}
return line, ok
}
// An ask the publisher publishes, and then asks past, while an intake is
// deciding against the line read before that publication is not lost: the
// intake must not enqueue it again, or a planned move would be minted twice.
func TestAnAskPublishedDuringTheIntakeIsNotEnqueuedAgain(t *testing.T) {
reader := newFakeBasisReader()
line := AuthorityBasis{Assigned: true, ReplicaID: "r1", Epoch: 1, EndpointVersion: 1, DataAddr: "d1", CtrlAddr: "c1"}
reader.Set("v1", "r1", line)
publishing := &publishOnRead{fakeBasisReader: reader}
ctrl := NewTopologyController(TopologyControllerConfig{}, publishing)
r1 := candidate("r1", "s1", "d1", "c1", 10)
r1.Reachable = false
snap := ClusterSnapshot{
CollectedRevision: 2,
Servers: []ServerObservation{
{ServerID: "s1", Reachable: true, Eligible: true},
{ServerID: "s2", Reachable: true, Eligible: true},
{ServerID: "s3", Reachable: true, Eligible: true},
},
Volumes: []VolumeTopologySnapshot{clusterVolume("v1", line, r1, candidate("r2", "s2", "d2", "c2", 20), candidate("r3", "s3", "d3", "c3", 10))},
}
if err := ctrl.SubmitClusterSnapshot(snap); err != nil {
t.Fatal(err)
}
if ask := nextAskOrFail(t, ctrl); ask.Intent != IntentReassign || ask.ReplicaID != "r2" {
t.Fatalf("first intake: %+v, want Reassign r2", ask)
}
ended, cancel := context.WithCancel(context.Background())
cancel()
publishing.skip = 1 // the intake's load count reads the line first
publishing.publish = func() {
reader.Set("v1", "r2", AuthorityBasis{Assigned: true, ReplicaID: "r2", Epoch: 2, EndpointVersion: 1, DataAddr: "d2", CtrlAddr: "c2"})
_, _ = ctrl.Next(ended) // published: the publisher is back for its next ask
}
if err := ctrl.SubmitClusterSnapshot(snap); err != nil {
t.Fatal(err)
}
if out := ctrl.LastOutcome("v1"); strings.HasPrefix(out, "enqueued again") {
t.Fatalf("an ask published during the intake was enqueued again: %q", out)
}
expectNoNext(t, ctrl)
}