Skip to content

Commit

Permalink
exeuctor: fix data race for test TestInterruptedDuringSort (pingcap#5…
Browse files Browse the repository at this point in the history
  • Loading branch information
wshwsh12 authored Jan 24, 2024
1 parent 87ffb95 commit 8aff603
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/executor/sortexec/sortexec_pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package sortexec

import (
"sync"
"testing"
"time"

Expand Down Expand Up @@ -62,12 +63,16 @@ func TestInterruptedDuringSort(t *testing.T) {
require.True(t, canadd)
}
var cancelTime time.Time
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
time.Sleep(200 * time.Millisecond)
rootTracker.Killer.SendKillSignal(sqlkiller.QueryInterrupted)
cancelTime = time.Now()
wg.Done()
}()
err := sp.sort()
wg.Wait()
cancelDuration := time.Since(cancelTime)
require.Less(t, cancelDuration, 1*time.Second)
require.True(t, exeerrors.ErrQueryInterrupted.Equal(err))
Expand Down Expand Up @@ -110,12 +115,16 @@ func TestInterruptedDuringSpilling(t *testing.T) {
err := sp.sort()
require.NoError(t, err)
var cancelTime time.Time
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
time.Sleep(200 * time.Millisecond)
rootTracker.Killer.SendKillSignal(sqlkiller.QueryInterrupted)
cancelTime = time.Now()
wg.Done()
}()
err = sp.spillToDisk(rootTracker)
wg.Wait()
cancelDuration := time.Since(cancelTime)
require.Less(t, cancelDuration, 1*time.Second)
require.True(t, exeerrors.ErrQueryInterrupted.Equal(err))
Expand Down

0 comments on commit 8aff603

Please sign in to comment.