Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: fix flaky test by correctly cancelling a query #57140

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/executor/temporary_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ func assertTemporaryTableNoNetwork(t *testing.T, createTable func(*testkit.TestK
tk.MustExec("insert into tmp_t values (1, 1, 1)")
tk.MustExec("insert into tmp_t values (2, 2, 2)")

// Make sure the fail point works.
// With that failpoint, all requests to the TiKV is discard.
rs, err := tk1.Exec("select * from normal")
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

rs, err := tk1.ExecWithContext(ctx, "select * from normal")
require.NoError(t, err)

blocked := make(chan struct{}, 1)
ctx, cancelFunc := context.WithCancel(context.Background())
done.Add(1)
go func() {
defer done.Done()
Expand All @@ -109,10 +109,10 @@ func assertTemporaryTableNoNetwork(t *testing.T, createTable func(*testkit.TestK

select {
case <-blocked:
cancelFunc()
cancel()
require.FailNow(t, "The query should block when the failpoint is enabled.")
case <-time.After(200 * time.Millisecond):
cancelFunc()
cancel()
}

// Check the temporary table do not send request to TiKV.
Expand Down