Skip to content

Commit

Permalink
remove ru token and set brust limit
Browse files Browse the repository at this point in the history
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
  • Loading branch information
CabinfeverB committed Feb 7, 2023
1 parent 391c551 commit 6f55148
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
8 changes: 4 additions & 4 deletions ddl/resource_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestResourceGroupBasic(t *testing.T) {
re.Equal(uint64(2000), g.RURate)
re.Equal(int64(-1), g.BurstLimit)

tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 2000 0 YES"))
tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 2000 YES"))

tk.MustExec("drop resource group x")
g = testResourceGroupNameFromIS(t, tk.Session(), "x")
Expand Down Expand Up @@ -137,15 +137,15 @@ func TestResourceGroupBasic(t *testing.T) {

// Check information schema table information_schema.resource_groups
tk.MustExec("create resource group x RU_PER_SEC=1000")
tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 1000 0 NO"))
tk.MustQuery("select * from information_schema.resource_groups where name = 'x'").Check(testkit.Rows("x 1000 NO"))
tk.MustQuery("show create resource group x").Check(testkit.Rows("x CREATE RESOURCE GROUP `x` RU_PER_SEC=1000"))

tk.MustExec("create resource group y RU_PER_SEC=2000")
tk.MustQuery("select * from information_schema.resource_groups where name = 'y'").Check(testkit.Rows("y 2000 0 NO"))
tk.MustQuery("select * from information_schema.resource_groups where name = 'y'").Check(testkit.Rows("y 2000 NO"))
tk.MustQuery("show create resource group y").Check(testkit.Rows("y CREATE RESOURCE GROUP `y` RU_PER_SEC=2000"))

tk.MustExec("alter resource group y RU_PER_SEC=4000 BURSTABLE")
tk.MustQuery("select * from information_schema.resource_groups where name = 'y'").Check(testkit.Rows("y 4000 0 YES"))
tk.MustQuery("select * from information_schema.resource_groups where name = 'y'").Check(testkit.Rows("y 4000 YES"))
tk.MustQuery("show create resource group y").Check(testkit.Rows("y CREATE RESOURCE GROUP `y` RU_PER_SEC=4000 BURSTABLE"))

tk.MustQuery("select count(*) from information_schema.resource_groups").Check(testkit.Rows("2"))
Expand Down
20 changes: 16 additions & 4 deletions ddl/resourcegroup/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ func NewGroupFromOptions(groupName string, options *model.ResourceGroupSettings)
if options.RURate > 0 {
isRUMode = true
group.Mode = rmpb.GroupMode_RUMode
burstLimit := options.BurstLimit
if burstLimit >= 0 {
burstLimit = int64(options.RURate)
}
group.RUSettings = &rmpb.GroupRequestUnitSettings{
RU: &rmpb.TokenBucket{
Settings: &rmpb.TokenLimitSettings{
FillRate: options.RURate,
BurstLimit: options.BurstLimit,
BurstLimit: burstLimit,
},
},
}
Expand Down Expand Up @@ -76,23 +80,31 @@ func NewGroupFromOptions(groupName string, options *model.ResourceGroupSettings)
}

group.Mode = rmpb.GroupMode_RawMode
cpuBurst := options.BurstLimit
ioReadBurst := options.BurstLimit
ioWriteBurst := options.BurstLimit
if options.BurstLimit >= 0 {
cpuBurst = int64(cpuRate)
ioReadBurst = int64(ioReadRate)
ioWriteBurst = int64(ioWriteRate)
}
group.RawResourceSettings = &rmpb.GroupRawResourceSettings{
Cpu: &rmpb.TokenBucket{
Settings: &rmpb.TokenLimitSettings{
FillRate: cpuRate,
BurstLimit: options.BurstLimit,
BurstLimit: cpuBurst,
},
},
IoRead: &rmpb.TokenBucket{
Settings: &rmpb.TokenLimitSettings{
FillRate: ioReadRate,
BurstLimit: options.BurstLimit,
BurstLimit: ioReadBurst,
},
},
IoWrite: &rmpb.TokenBucket{
Settings: &rmpb.TokenLimitSettings{
FillRate: ioWriteRate,
BurstLimit: options.BurstLimit,
BurstLimit: ioWriteBurst,
},
},
}
Expand Down
2 changes: 0 additions & 2 deletions executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3406,7 +3406,6 @@ func (e *memtableRetriever) setDataFromResourceGroups() error {
row := types.MakeDatums(
group.Name,
group.RUSettings.RU.Settings.FillRate,
uint64(group.RUSettings.RU.Tokens),
burstable,
)
rows = append(rows, row)
Expand All @@ -3416,7 +3415,6 @@ func (e *memtableRetriever) setDataFromResourceGroups() error {
group.Name,
nil,
nil,
nil,
)
rows = append(rows, row)
}
Expand Down
1 change: 0 additions & 1 deletion infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,6 @@ var tableMemoryUsageOpsHistoryCols = []columnInfo{
var tableResourceGroupsCols = []columnInfo{
{name: "NAME", tp: mysql.TypeVarchar, size: resourcegroup.MaxGroupNameLength, flag: mysql.NotNullFlag},
{name: "RU_PER_SEC", tp: mysql.TypeLonglong, size: 21},
{name: "RU_TOKENS", tp: mysql.TypeLonglong, size: 21},
{name: "BURSTABLE", tp: mysql.TypeVarchar, size: 3},
}

Expand Down

0 comments on commit 6f55148

Please sign in to comment.