Skip to content

Commit 06da9d7

Browse files
authored
pkg/resourcegroup: fix unstable TestResourceGroupRunaway (#65780)
close #62452
1 parent 3e15cf8 commit 06da9d7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pkg/resourcegroup/tests/resource_group_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,19 @@ func TestResourceGroupRunaway(t *testing.T) {
346346
tk.MustExec("insert into t values(1)")
347347

348348
tk.MustExec("set global tidb_enable_resource_control='on'")
349-
tk.MustExec("create resource group rg1 RU_PER_SEC=1000 QUERY_LIMIT=(EXEC_ELAPSED='50ms' ACTION=KILL)")
350-
tk.MustExec("create resource group rg2 BURSTABLE=MODERATED RU_PER_SEC=2000 QUERY_LIMIT=(EXEC_ELAPSED='50ms' action KILL WATCH EXACT duration '1s')")
351-
tk.MustExec("create resource group rg3 BURSTABLE=MODERATED RU_PER_SEC=2000 QUERY_LIMIT=(EXEC_ELAPSED='50ms' action KILL WATCH EXACT)")
352-
tk.MustQuery("select * from information_schema.resource_groups where name = 'rg2'").Check(testkit.Rows("rg2 2000 MEDIUM MODERATED EXEC_ELAPSED='50ms', ACTION=KILL, WATCH=EXACT DURATION='1s' <nil>"))
353-
tk.MustQuery("select * from information_schema.resource_groups where name = 'rg3'").Check(testkit.Rows("rg3 2000 MEDIUM MODERATED EXEC_ELAPSED='50ms', ACTION=KILL, WATCH=EXACT DURATION=UNLIMITED <nil>"))
349+
// Create resource groups without query limit first, since the `EXEC_ELAPSED='50ms'` threshold
350+
// can be exceeded on slow/loaded CI machines even for a simple query.
351+
tk.MustExec("create resource group rg1 RU_PER_SEC=1000 QUERY_LIMIT=()")
352+
tk.MustExec("create resource group rg2 BURSTABLE=MODERATED RU_PER_SEC=2000 QUERY_LIMIT=()")
353+
tk.MustExec("create resource group rg3 BURSTABLE=MODERATED RU_PER_SEC=2000 QUERY_LIMIT=()")
354354
tk.MustQuery("select /*+ resource_group(rg1) */ * from t").Check(testkit.Rows("1"))
355355
tk.MustQuery("select /*+ resource_group(rg2) */ * from t").Check(testkit.Rows("1"))
356356
tk.MustQuery("select /*+ resource_group(rg3) */ * from t").Check(testkit.Rows("1"))
357+
tk.MustExec("alter resource group rg1 RU_PER_SEC=1000 QUERY_LIMIT=(EXEC_ELAPSED='50ms' ACTION=KILL)")
358+
tk.MustExec("alter resource group rg2 RU_PER_SEC=2000 QUERY_LIMIT=(EXEC_ELAPSED='50ms' action KILL WATCH EXACT duration '1s')")
359+
tk.MustExec("alter resource group rg3 RU_PER_SEC=2000 QUERY_LIMIT=(EXEC_ELAPSED='50ms' action KILL WATCH EXACT)")
360+
tk.MustQuery("select * from information_schema.resource_groups where name = 'rg2'").Check(testkit.Rows("rg2 2000 MEDIUM MODERATED EXEC_ELAPSED='50ms', ACTION=KILL, WATCH=EXACT DURATION='1s' <nil>"))
361+
tk.MustQuery("select * from information_schema.resource_groups where name = 'rg3'").Check(testkit.Rows("rg3 2000 MEDIUM MODERATED EXEC_ELAPSED='50ms', ACTION=KILL, WATCH=EXACT DURATION=UNLIMITED <nil>"))
357362

358363
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/store/copr/sleepCoprRequest", fmt.Sprintf("return(%d)", 60)))
359364
err := tk.QueryToErr("select /*+ resource_group(rg1) */ * from t")

0 commit comments

Comments
 (0)