From 02f4c8dfe06c3206a3eb891565406b14ff35dc0b Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 5 Dec 2026 22:11:55 -0800 Subject: [PATCH] mq broker test: wait for the follower's ack before retiring the leader (#13490) TestRetiredLeaderClosesItsFollowerOnlyWhenAllIsStored retired the partition right after an unacked publish. When the abandon closed the client connection before gRPC's writer goroutine had sent the follow stream's headers, the transport refused to start the stream, so the follower never saw it and could not report it broken. A publisher only gets its ack once the follower holds the entry, so wait for that ack as well. Co-authored-by: Claude Opus 5.5 --- weed/mq/broker/broker_replication_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/weed/mq/broker/broker_replication_test.go b/weed/mq/broker/broker_replication_test.go index 0b6b68531c..22a6a65321 100644 --- a/weed/mq/broker/broker_replication_test.go +++ b/weed/mq/broker/broker_replication_test.go @@ -409,7 +409,12 @@ func TestRetiredLeaderClosesItsFollowerOnlyWhenAllIsStored(t *testing.T) { lp := topic.NewLocalPartition(fenceTestPartition, 3600, flush, nil) lp.Replica = startReplica(t, addr) manager.AddLocalPartition(fenceTestTopic, lp) - if _, err := lp.PublishWithOffset(&mq_pb.DataMessage{Key: []byte("k"), Value: []byte("v"), TsNs: time.Now().UnixNano()}); err != nil { + offset, err := lp.PublishWithOffset(&mq_pb.DataMessage{Key: []byte("k"), Value: []byte("v"), TsNs: time.Now().UnixNano()}) + if err != nil { + t.Fatal(err) + } + // as before a publish is acked; a stream closed before it is sent never reaches the follower + if err := lp.Replica.WaitAcked(offset); err != nil { t.Fatal(err) } manager.RemoveLocalPartition(fenceTestTopic, lp)