From 056838551354b3299271760289403a6ed164f304 Mon Sep 17 00:00:00 2001 From: Shenghui Wu <793703860@qq.com> Date: Wed, 24 Jan 2024 15:54:23 +0800 Subject: [PATCH] executor: fix data race for test TestInterruptedDuringSpilling (#50693) close pingcap/tidb#50688 --- pkg/util/chunk/row_container_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/util/chunk/row_container_test.go b/pkg/util/chunk/row_container_test.go index 03a86c7be2f54..993e5209e6741 100644 --- a/pkg/util/chunk/row_container_test.go +++ b/pkg/util/chunk/row_container_test.go @@ -533,13 +533,17 @@ func TestInterruptedDuringSpilling(t *testing.T) { for i := 0; i < 102400; i++ { rc.Add(chk) } + wg := sync.WaitGroup{} + wg.Add(1) var cancelTime time.Time go func() { time.Sleep(200 * time.Millisecond) rootTracker.Killer.SendKillSignal(sqlkiller.QueryInterrupted) cancelTime = time.Now() + wg.Done() }() rc.spillToDisk(nil) + wg.Wait() cancelDuration := time.Since(cancelTime) require.Less(t, cancelDuration, 1*time.Second) }