From cd0d17bcd881253873b18f7aa4efe69e62e7d647 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 25 Nov 2026 12:04:48 -0800 Subject: [PATCH] replication: the redial control waits for the dropped connection The control slept a fixed time and could pass with no connection accepted and dropped. It now waits for the listener's accept-then-drop and fails if none happened; without the transport fix it fails at the store assertion. Co-Authored-By: Claude Opus 5.5 --- .../core/replication/store_learn_bringup_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/seaweed-block/core/replication/store_learn_bringup_test.go b/seaweed-block/core/replication/store_learn_bringup_test.go index 73221a849c..ca359d8163 100644 --- a/seaweed-block/core/replication/store_learn_bringup_test.go +++ b/seaweed-block/core/replication/store_learn_bringup_test.go @@ -123,6 +123,7 @@ func TestStoreLearnerRedialsAfterABrokenConnection(t *testing.T) { t.Fatal(err) } addr := drop.Addr().String() + dropped := make(chan struct{}, 64) go func() { for { c, err := drop.Accept() @@ -130,6 +131,10 @@ func TestStoreLearnerRedialsAfterABrokenConnection(t *testing.T) { return } _ = c.Close() // connected, then the read fails + select { + case dropped <- struct{}{}: + default: + } } }() v := NewReplicationVolume("v", storage.NewBlockStore(64, 4096)) @@ -138,7 +143,12 @@ func TestStoreLearnerRedialsAfterABrokenConnection(t *testing.T) { if err := v.UpdateReplicaSet(1, []ReplicaTarget{{ReplicaID: "r2", DataAddr: addr, ControlAddr: addr, Epoch: 1, EndpointVersion: 1}}); err != nil { t.Fatal(err) } - time.Sleep(400 * time.Millisecond) // a few connected, failed attempts + // The learner did hold a connection whose read failed. + select { + case <-dropped: + case <-time.After(10 * time.Second): + t.Fatal("no learner barrier was accepted and dropped: the schedule did not run") + } _ = drop.Close() s, err := storage.CreateWALStore(filepath.Join(t.TempDir(), "r2.wal"), 64, 4096)