From 731b1118eb0d4a4b406ee2dd16ec0965e49fd250 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Wed, 18 Nov 2026 04:23:00 -0800 Subject: [PATCH] test(replication): retain WAL for both RF2 catch-up sessions across checkpoint --- .../component/qa_g5_scenarios_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/seaweed-block/core/replication/component/qa_g5_scenarios_test.go b/seaweed-block/core/replication/component/qa_g5_scenarios_test.go index 421bf2a2f6..a12f2f7e1e 100644 --- a/seaweed-block/core/replication/component/qa_g5_scenarios_test.go +++ b/seaweed-block/core/replication/component/qa_g5_scenarios_test.go @@ -43,6 +43,7 @@ import ( "time" "github.com/seaweedfs/seaweed-block/core/replication/component" + "github.com/seaweedfs/seaweed-block/core/storage" ) // TestG5_QA_LaneDiscipline_LiveAndRecoveryConcurrent_MultiReplica was @@ -125,10 +126,28 @@ func TestG5_QA_RF2_BothReplicasReachByteEqual(t *testing.T) { component.RunMatrix(t, func(t *testing.T, c *component.Cluster) { c.WithReplicas(2).WithApplyGate().Start() + // This scenario requires WAL replay from genesis for both replicas. + // Retain those 30 records even when checkpointing wins the race. + if s, ok := c.Primary().Store.(*storage.WALStore); ok { + s.SetRecoveryRetentionLSNs(30) + } + // Write 30 LBAs on primary. c.PrimaryWriteN(30) c.PrimarySync() + // Exercise both WAL catch-ups after the real checkpoint, rather than + // depending on completion before the background flusher runs. + if s, ok := c.Primary().Store.(*storage.WALStore); ok { + deadline := time.Now().Add(5 * time.Second) + for s.CheckpointLSN() < 30 && time.Now().Before(deadline) { + time.Sleep(time.Millisecond) + } + if s.CheckpointLSN() < 30 { + t.Fatal("primary did not checkpoint the test writes") + } + } + // Both replicas catch up independently (single catch-up per // replica avoids sessionID=1 collision per known carry). for i := 0; i < 2; i++ {