diff --git a/pkg/executor/test/cte/cte_test.go b/pkg/executor/test/cte/cte_test.go index 1bebfa025e5e6..513c978c49eb3 100644 --- a/pkg/executor/test/cte/cte_test.go +++ b/pkg/executor/test/cte/cte_test.go @@ -167,11 +167,15 @@ func TestCTEDelSpillFile(t *testing.T) { tk.MustExec("drop table if exists t1, t2;") tk.MustExec("create table t1(c1 int, c2 int);") tk.MustExec("create table t2(c1 int);") - tk.MustExec("set @@cte_max_recursion_depth = 1000000;") - tk.MustExec("set global tidb_mem_oom_action = 'log';") - tk.MustExec("set @@tidb_mem_quota_query = 100;") tk.MustExec("insert into t2 values(1);") - tk.MustExec("insert into t1 (c1, c2) with recursive cte1 as (select c1 from t2 union select cte1.c1 + 1 from cte1 where cte1.c1 < 100000) select cte1.c1, cte1.c1+1 from cte1;") + tk.MustExec("set @@cte_max_recursion_depth = 100;") + tk.MustExec("set @@tidb_mem_quota_query = 100;") + tk.MustExec("set global tidb_mem_oom_action = 'cancel';") + // Make sure the OOM happens. + tk.MustExecToErr("insert into t1 (c1, c2) with recursive cte1 as (select c1 from t2 union select cte1.c1 + 1 from cte1 where cte1.c1 < 100) select cte1.c1, cte1.c1+1 from cte1;") + tk.MustExec("set global tidb_mem_oom_action = 'log';") + // Test that the storage is cleaned as expected. + tk.MustExec("insert into t1 (c1, c2) with recursive cte1 as (select c1 from t2 union select cte1.c1 + 1 from cte1 where cte1.c1 < 100) select cte1.c1, cte1.c1+1 from cte1;") require.Nil(t, tk.Session().GetSessionVars().StmtCtx.CTEStorageMap) } diff --git a/pkg/infoschema/test/clustertablestest/cluster_tables_test.go b/pkg/infoschema/test/clustertablestest/cluster_tables_test.go index ca2fefc95a083..cda6e486bd487 100644 --- a/pkg/infoschema/test/clustertablestest/cluster_tables_test.go +++ b/pkg/infoschema/test/clustertablestest/cluster_tables_test.go @@ -911,7 +911,8 @@ func TestMDLView(t *testing.T) { } } -func TestMDLViewPrivilege(t *testing.T) { +func TestMDLViewWithNoPrivilege(t *testing.T) { + // It's with TestMDLViewWithPrivilege. Split to two tests just because it runs too much time. store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store) require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil, nil)) @@ -920,9 +921,14 @@ func TestMDLViewPrivilege(t *testing.T) { require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "test", Hostname: "%"}, nil, nil, nil)) _, err := tk.Exec("select * from mysql.tidb_mdl_view;") require.ErrorContains(t, err, "view lack rights") +} +func TestMDLViewWithPrivilege(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) // grant all privileges to test user. require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil, nil)) + tk.MustExec("create user 'test'@'%' identified by '';") tk.MustExec("grant all privileges on *.* to 'test'@'%';") tk.MustExec("flush privileges;") require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "test", Hostname: "%"}, nil, nil, nil)) diff --git a/pkg/planner/core/memtable_infoschema_extractor_test.go b/pkg/planner/core/memtable_infoschema_extractor_test.go index bcc61d1e688c8..cf429e7495c92 100644 --- a/pkg/planner/core/memtable_infoschema_extractor_test.go +++ b/pkg/planner/core/memtable_infoschema_extractor_test.go @@ -390,6 +390,12 @@ func TestMemtableInfoschemaExtractorPart1(t *testing.T) { prepareData: prepareDataViews, cleanData: cleanDataViews, }, + } + testMemtableInfoschemaExtractor(t, tcs) +} + +func TestMemtableInfoschemaExtractorPart2(t *testing.T) { + tcs := []testCase{ { memTableName: infoschema.TableKeyColumn, prepareData: prepareDataKeyColumnUsage, @@ -409,7 +415,7 @@ func TestMemtableInfoschemaExtractorPart1(t *testing.T) { testMemtableInfoschemaExtractor(t, tcs) } -func TestMemtableInfoschemaExtractorPart2(t *testing.T) { +func TestMemtableInfoschemaExtractorPart3(t *testing.T) { tcs := []testCase{ { memTableName: infoschema.TableStatistics, @@ -426,6 +432,12 @@ func TestMemtableInfoschemaExtractorPart2(t *testing.T) { prepareData: prepareDataCheckConstraints, cleanData: cleanDataCheckConstraints, }, + } + testMemtableInfoschemaExtractor(t, tcs) +} + +func TestMemtableInfoschemaExtractorPart4(t *testing.T) { + tcs := []testCase{ { memTableName: infoschema.TableTiDBCheckConstraints, prepareData: prepareDataTidbCheckConstraints, diff --git a/pkg/planner/core/plan_cost_ver1_test.go b/pkg/planner/core/plan_cost_ver1_test.go index 5320c0e618091..496a916e1f963 100644 --- a/pkg/planner/core/plan_cost_ver1_test.go +++ b/pkg/planner/core/plan_cost_ver1_test.go @@ -103,7 +103,7 @@ func TestScanOnSmallTable(t *testing.T) { tk.MustExec("use test") tk.MustExec(`create table t (a int)`) tk.MustExec("insert into t values (1), (2), (3), (4), (5)") - tk.MustExec("analyze table t") + tk.MustExec("analyze table t all columns") tk.MustExec(`set @@tidb_cost_model_version=2`) // Create virtual tiflash replica info. diff --git a/pkg/server/handler/tests/http_handler_serial_test.go b/pkg/server/handler/tests/http_handler_serial_test.go index 6ba324dc2a38f..f9e9a6b3e30b8 100644 --- a/pkg/server/handler/tests/http_handler_serial_test.go +++ b/pkg/server/handler/tests/http_handler_serial_test.go @@ -454,11 +454,10 @@ func TestDebugRoutes(t *testing.T) { "/debug/pprof/block?debug=1", "/debug/pprof/threadcreate?debug=1", "/debug/pprof/cmdline", - "/debug/pprof/profile", + "/debug/pprof/profile?seconds=5", "/debug/pprof/mutex?debug=1", "/debug/pprof/symbol", "/debug/pprof/trace", - "/debug/pprof/profile", "/debug/gogc", // "/debug/zip", // this creates unexpected goroutines which will make goleak complain, so we skip it for now "/debug/ballast-object-sz",