Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource_control: fix burst patch #48141

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
nolouch marked this conversation as resolved.
Show resolved Hide resolved
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the issue, we can see the result as follows:

create resource group rg3 ru_per_sec=2000;
alter resource group rg3 ru_per_sec=5000;
2. What did you expect to see? (Required)
burst_limit = 2000

So why here is 6000 not 4000?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sry, I wrote the wrong ddl statement in the issue. It should be
create resource group rg3 ru_per_sec= 5000;
alter resource group rg3 ru_per_sec=2000;

}
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