From 3edde027082c2afdc559b44aabcaca81df6bc6fa Mon Sep 17 00:00:00 2001 From: Yifan Xu <30385241+xuyifangreeneyes@users.noreply.github.com> Date: Mon, 19 Dec 2022 15:12:54 +0800 Subject: [PATCH] executor: fix unstable TestMaxPreparedStmtCount (#40024) ref pingcap/tidb#39735 --- executor/prepared_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/executor/prepared_test.go b/executor/prepared_test.go index b7930cf2703c7..739ba1c0cd659 100644 --- a/executor/prepared_test.go +++ b/executor/prepared_test.go @@ -18,6 +18,7 @@ import ( "fmt" "strconv" "strings" + "sync/atomic" "testing" "github.com/pingcap/tidb/parser/auth" @@ -1258,6 +1259,11 @@ func TestIssue31141(t *testing.T) { } func TestMaxPreparedStmtCount(t *testing.T) { + oldVal := atomic.LoadInt64(&variable.PreparedStmtCount) + atomic.StoreInt64(&variable.PreparedStmtCount, 0) + defer func() { + atomic.StoreInt64(&variable.PreparedStmtCount, oldVal) + }() store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) tk.MustExec("set @@global.max_prepared_stmt_count = 2")