Skip to content

Commit

Permalink
resource_control: fix burst patch (#48141) (#48382)
Browse files Browse the repository at this point in the history
close #48140
  • Loading branch information
ti-chi-bot authored Nov 8, 2023
1 parent d50e74d commit 62ec8a7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
35 changes: 34 additions & 1 deletion pkg/ddl/tests/resourcegroup/resource_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,28 @@ func TestResourceGroupBasic(t *testing.T) {
}
g = testResourceGroupNameFromIS(t, tk.Session(), "y")
checkFunc(g)
tk.MustGetErrCode("alter resource group y PRIORITY=hight", mysql.ErrParse)
tk.MustExec("alter resource group y PRIORITY=high")
checkFunc = func(groupInfo *model.ResourceGroupInfo) {
re.Equal(true, groupInfo.ID != 0)
re.Equal("y", groupInfo.Name.L)
re.Equal(groupID.Load(), groupInfo.ID)
re.Equal(uint64(4000), groupInfo.RURate)
re.Equal(int64(4000), groupInfo.BurstLimit)
re.Equal(uint64(16), groupInfo.Priority)
}
g = testResourceGroupNameFromIS(t, tk.Session(), "y")
checkFunc(g)
tk.MustExec("alter resource group y RU_PER_SEC=6000")
checkFunc = func(groupInfo *model.ResourceGroupInfo) {
re.Equal(true, groupInfo.ID != 0)
re.Equal("y", groupInfo.Name.L)
re.Equal(groupID.Load(), groupInfo.ID)
re.Equal(uint64(6000), groupInfo.RURate)
re.Equal(int64(6000), groupInfo.BurstLimit)
}
g = testResourceGroupNameFromIS(t, tk.Session(), "y")
checkFunc(g)
tk.MustExec("alter resource group y BURSTABLE RU_PER_SEC=5000 QUERY_LIMIT=(EXEC_ELAPSED='15s' ACTION KILL)")
checkFunc = func(groupInfo *model.ResourceGroupInfo) {
re.Equal(true, groupInfo.ID != 0)
Expand All @@ -150,7 +172,18 @@ func TestResourceGroupBasic(t *testing.T) {
}
g = testResourceGroupNameFromIS(t, tk.Session(), "y")
checkFunc(g)
tk.MustQuery("select * from information_schema.resource_groups where name = 'y'").Check(testkit.Rows("y 5000 MEDIUM YES EXEC_ELAPSED='15s', ACTION=KILL <nil>"))
tk.MustExec("alter resource group y RU_PER_SEC=6000 BURSTABLE=false")
checkFunc = func(groupInfo *model.ResourceGroupInfo) {
re.Equal(true, groupInfo.ID != 0)
re.Equal("y", groupInfo.Name.L)
re.Equal(groupID.Load(), groupInfo.ID)
re.Equal(uint64(6000), groupInfo.RURate)
re.Equal(int64(6000), groupInfo.BurstLimit)
}
g = testResourceGroupNameFromIS(t, tk.Session(), "y")
checkFunc(g)
tk.MustExec("alter resource group y RU_PER_SEC=5000 BURSTABLE")
tk.MustQuery("select * from information_schema.resource_groups where name = 'y'").Check(testkit.Rows("y 5000 HIGH YES EXEC_ELAPSED='15s', ACTION=KILL <nil>"))
tk.MustExec("drop resource group y")
g = testResourceGroupNameFromIS(t, tk.Session(), "y")
re.Nil(g)
Expand Down
4 changes: 2 additions & 2 deletions pkg/parser/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -2079,8 +2079,8 @@ func (p *ResourceGroupSettings) String() string {

// Adjust adjusts the resource group settings.
func (p *ResourceGroupSettings) Adjust() {
// Curretly we only support ru_per_sec sytanx, so BurstLimit(capicity) is always same as ru_per_sec.
if p.BurstLimit == 0 {
// Curretly we only support ru_per_sec sytanx, so BurstLimit(capicity) is always same as ru_per_sec except burstable.
if p.BurstLimit >= 0 {
p.BurstLimit = int64(p.RURate)
}
}
Expand Down

0 comments on commit 62ec8a7

Please sign in to comment.