diff --git a/pkg/statistics/handle/autoanalyze/refresher/refresher_test.go b/pkg/statistics/handle/autoanalyze/refresher/refresher_test.go index 68c0724c37f28..4061fa9ef8c4b 100644 --- a/pkg/statistics/handle/autoanalyze/refresher/refresher_test.go +++ b/pkg/statistics/handle/autoanalyze/refresher/refresher_test.go @@ -404,7 +404,10 @@ func TestAnalyzeHighestPriorityTablesWithFailedAnalysis(t *testing.T) { r := refresher.NewRefresher(handle, sysProcTracker, dom.DDLNotifier()) defer r.Close() - r.AnalyzeHighestPriorityTables(tk.Session()) + require.NoError(t, util.CallWithSCtx(handle.SPool(), func(sctx sessionctx.Context) error { + require.True(t, r.AnalyzeHighestPriorityTables(sctx)) + return nil + })) r.WaitAutoAnalyzeFinishedForTest() is := dom.InfoSchema()