From 73936e147fb58fb3bab98e1855598bb832b5daad Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Thu, 13 Feb 2025 14:25:07 +0800 Subject: [PATCH] fix: data race in load test Signed-off-by: Wei Liu --- tests/integration/replicas/load/load_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/integration/replicas/load/load_test.go b/tests/integration/replicas/load/load_test.go index 564a6dcc6b8f5..8346b30be5b58 100644 --- a/tests/integration/replicas/load/load_test.go +++ b/tests/integration/replicas/load/load_test.go @@ -21,6 +21,7 @@ import ( "fmt" "path" "strings" + "sync" "testing" "time" @@ -988,8 +989,11 @@ func (s *LoadTestSuite) TestLoadWithCompact() { s.releaseCollection(dbName, collName) stopInsertCh := make(chan struct{}, 1) + wg := &sync.WaitGroup{} + wg.Add(1) // Start a goroutine to continuously insert data and trigger compaction go func() { + defer wg.Done() for { select { case <-stopInsertCh: @@ -1023,6 +1027,7 @@ func (s *LoadTestSuite) TestLoadWithCompact() { // Clean up close(stopInsertCh) + wg.Wait() s.releaseCollection(dbName, collName) }