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

*: unify wru,rru to ru #40884

Merged
merged 6 commits into from
Feb 2, 2023
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
15 changes: 11 additions & 4 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3342,8 +3342,8 @@ def go_deps():
name = "com_github_pingcap_kvproto",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/kvproto",
sum = "h1:LB+BrfyO5fsz5pwN3V4HvTrpZTAmsjB4VkCEBLbjYUw=",
version = "v0.0.0-20230119031034-25f1909b7934",
sum = "h1:oYUK4V5PMlyIooU/+pPkKrJ3vELwcuuCNyKKlqSQa5c=",
version = "v0.0.0-20230131104319-a7c51106dfe7",
)
go_repository(
name = "com_github_pingcap_log",
Expand Down Expand Up @@ -4062,8 +4062,8 @@ def go_deps():
name = "com_github_tikv_pd",
build_file_proto_mode = "disable",
importpath = "github.com/tikv/pd",
sum = "h1:cj3bhdIBJcLL2304EDEmd3eX+r73+hbGSYRFn/APiDU=",
version = "v1.1.0-beta.0.20230119114149-402c2bfee2f3",
sum = "h1:ef+kODGby/rmF9fabJzqRM15NcGufkTRftROdy7jvAk=",
version = "v1.1.0-beta.0.20230201064005-6ca9a3398f15",
)

go_repository(
Expand Down Expand Up @@ -6079,3 +6079,10 @@ def go_deps():
sum = "h1:RwpqwwFKBAa2h+F6pMEGpE707Edld0etUD3GhqqhDNc=",
version = "v1.7.0",
)
go_repository(
name = "tools_gotest_v3",
build_file_proto_mode = "disable",
importpath = "gotest.tools/v3",
sum = "h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=",
version = "v3.0.3",
)
6 changes: 2 additions & 4 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3036,10 +3036,8 @@ func SetDirectPlacementOpt(placementSettings *model.PlacementSettings, placement
// SetDirectResourceGroupUnit tries to set the ResourceGroupSettings.
func SetDirectResourceGroupUnit(resourceGroupSettings *model.ResourceGroupSettings, typ ast.ResourceUnitType, stringVal string, uintVal uint64) error {
switch typ {
case ast.ResourceRRURate:
resourceGroupSettings.RRURate = uintVal
case ast.ResourceWRURate:
resourceGroupSettings.WRURate = uintVal
case ast.ResourceRURate:
resourceGroupSettings.RURate = uintVal
case ast.ResourceUnitCPU:
resourceGroupSettings.CPULimiter = stringVal
case ast.ResourceUnitIOReadBandwidth:
Expand Down
65 changes: 21 additions & 44 deletions ddl/resource_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,23 @@ func TestResourceGroupBasic(t *testing.T) {
tk.MustGetErrCode("create user usr1 resource group rg1", mysql.ErrResourceGroupSupportDisabled)
tk.MustExec("create user usr1")
tk.MustGetErrCode("alter user usr1 resource group rg1", mysql.ErrResourceGroupSupportDisabled)
tk.MustGetErrCode("create resource group x "+
"RRU_PER_SEC=1000 "+
"WRU_PER_SEC=2000", mysql.ErrResourceGroupSupportDisabled)
tk.MustGetErrCode("create resource group x RU_PER_SEC=1000 ", mysql.ErrResourceGroupSupportDisabled)

tk.MustExec("set global tidb_enable_resource_control = 'on'")

tk.MustExec("create resource group x " +
"RRU_PER_SEC=1000 " +
"WRU_PER_SEC=2000")
tk.MustExec("create resource group x RU_PER_SEC=1000")
checkFunc := func(groupInfo *model.ResourceGroupInfo) {
require.Equal(t, true, groupInfo.ID != 0)
require.Equal(t, "x", groupInfo.Name.L)
require.Equal(t, groupID, groupInfo.ID)
require.Equal(t, uint64(1000), groupInfo.RRURate)
require.Equal(t, uint64(2000), groupInfo.WRURate)
require.Equal(t, uint64(1000), groupInfo.RURate)
}
// Check the group is correctly reloaded in the information schema.
g := testResourceGroupNameFromIS(t, tk.Session(), "x")
checkFunc(g)

// test create if not exists
tk.MustExec("create resource group if not exists x " +
"RRU_PER_SEC=10000 " +
"WRU_PER_SEC=20000")
tk.MustExec("create resource group if not exists x RU_PER_SEC=10000")
// Check the resource group is not changed
g = testResourceGroupNameFromIS(t, tk.Session(), "x")
checkFunc(g)
Expand All @@ -84,33 +77,23 @@ func TestResourceGroupBasic(t *testing.T) {
res.Check(testkit.Rows("Note 8248 Resource group 'x' already exists"))

tk.MustExec("set global tidb_enable_resource_control = DEFAULT")
tk.MustGetErrCode("alter resource group x "+
"RRU_PER_SEC=2000 "+
"WRU_PER_SEC=3000", mysql.ErrResourceGroupSupportDisabled)
tk.MustGetErrCode("alter resource group x RU_PER_SEC=2000 ", mysql.ErrResourceGroupSupportDisabled)
tk.MustGetErrCode("drop resource group x ", mysql.ErrResourceGroupSupportDisabled)

tk.MustExec("set global tidb_enable_resource_control = 'on'")

tk.MustGetErrCode("create resource group x "+
"RRU_PER_SEC=1000 "+
"WRU_PER_SEC=2000", mysql.ErrResourceGroupExists)
tk.MustGetErrCode("create resource group x RU_PER_SEC=1000 ", mysql.ErrResourceGroupExists)

tk.MustExec("alter resource group x " +
"RRU_PER_SEC=2000 " +
"WRU_PER_SEC=3000")
tk.MustExec("alter resource group x RU_PER_SEC=2000")
g = testResourceGroupNameFromIS(t, tk.Session(), "x")
re.Equal(uint64(2000), g.RRURate)
re.Equal(uint64(3000), g.WRURate)
re.Equal(uint64(2000), g.RURate)

tk.MustExec("alter resource group if exists not_exists " +
"RRU_PER_SEC=2000 " +
"WRU_PER_SEC=3000")
tk.MustExec("alter resource group if exists not_exists RU_PER_SEC=2000")
// Check warning message
res = tk.MustQuery("show warnings")
res.Check(testkit.Rows("Note 8249 Unknown resource group 'not_exists'"))

tk.MustQuery("select * from information_schema.resource_groups where group_name = 'x'").Check(testkit.Rows(strconv.FormatInt(g.ID, 10) + " x 2000 3000"))

tk.MustQuery("select * from information_schema.resource_groups where group_name = 'x' ").Check(testkit.Rows(strconv.FormatInt(g.ID, 10) + " x 2000"))
tk.MustExec("drop resource group x")
g = testResourceGroupNameFromIS(t, tk.Session(), "x")
re.Nil(g)
Expand Down Expand Up @@ -146,40 +129,34 @@ func TestResourceGroupBasic(t *testing.T) {
tk.MustExec("drop resource group y")
g = testResourceGroupNameFromIS(t, tk.Session(), "y")
re.Nil(g)
tk.MustContainErrMsg("create resource group x RRU_PER_SEC=1000, CPU='8000m';", resourcegroup.ErrInvalidResourceGroupDuplicatedMode.Error())
tk.MustContainErrMsg("create resource group x RU_PER_SEC=1000, CPU='8000m';", resourcegroup.ErrInvalidResourceGroupDuplicatedMode.Error())
groups, err := infosync.GetAllResourceGroups(context.TODO())
require.Equal(t, 0, len(groups))
require.NoError(t, err)

// Check information schema table information_schema.resource_groups
tk.MustExec("create resource group x " +
"RRU_PER_SEC=1000 " +
"WRU_PER_SEC=2000")
tk.MustExec("create resource group x RU_PER_SEC=1000")
g1 := testResourceGroupNameFromIS(t, tk.Session(), "x")
tk.MustQuery("select * from information_schema.resource_groups where group_name = 'x'").Check(testkit.Rows(strconv.FormatInt(g1.ID, 10) + " x 1000 2000"))
tk.MustQuery("show create resource group x").Check(testkit.Rows("x CREATE RESOURCE GROUP `x` RRU_PER_SEC=1000 WRU_PER_SEC=2000"))
tk.MustQuery("select * from information_schema.resource_groups where group_name = 'x'").Check(testkit.Rows(strconv.FormatInt(g1.ID, 10) + " x 1000"))
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 " +
"RRU_PER_SEC=2000 " +
"WRU_PER_SEC=3000")
tk.MustExec("create resource group y RU_PER_SEC=2000")
g2 := testResourceGroupNameFromIS(t, tk.Session(), "y")
tk.MustQuery("select * from information_schema.resource_groups where group_name = 'y'").Check(testkit.Rows(strconv.FormatInt(g2.ID, 10) + " y 2000 3000"))
tk.MustQuery("show create resource group y").Check(testkit.Rows("y CREATE RESOURCE GROUP `y` RRU_PER_SEC=2000 WRU_PER_SEC=3000"))
tk.MustQuery("select * from information_schema.resource_groups where group_name = 'y'").Check(testkit.Rows(strconv.FormatInt(g2.ID, 10) + " y 2000"))
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 " +
"RRU_PER_SEC=4000 " +
"WRU_PER_SEC=2000")
tk.MustExec("alter resource group y RU_PER_SEC=4000")

g2 = testResourceGroupNameFromIS(t, tk.Session(), "y")
tk.MustQuery("select * from information_schema.resource_groups where group_name = 'y'").Check(testkit.Rows(strconv.FormatInt(g2.ID, 10) + " y 4000 2000"))
tk.MustQuery("show create resource group y").Check(testkit.Rows("y CREATE RESOURCE GROUP `y` RRU_PER_SEC=4000 WRU_PER_SEC=2000"))
tk.MustQuery("select * from information_schema.resource_groups where group_name = 'y'").Check(testkit.Rows(strconv.FormatInt(g2.ID, 10) + " y 4000"))
tk.MustQuery("show create resource group y").Check(testkit.Rows("y CREATE RESOURCE GROUP `y` RU_PER_SEC=4000"))

tk.MustQuery("select count(*) from information_schema.resource_groups").Check(testkit.Rows("2"))
tk.MustGetErrCode("create user usr_fail resource group nil_group", mysql.ErrResourceGroupNotExists)
tk.MustExec("create user user2")
tk.MustGetErrCode("alter user user2 resource group nil_group", mysql.ErrResourceGroupNotExists)

tk.MustExec("create resource group do_not_delete_rg rru_per_sec=100 wru_per_sec=200")
tk.MustExec("create resource group do_not_delete_rg ru_per_sec=100")
tk.MustExec("create user usr3 resource group do_not_delete_rg")
tk.MustContainErrMsg("drop resource group do_not_delete_rg", "user [usr3] depends on the resource group to drop")
}
Expand Down
11 changes: 3 additions & 8 deletions ddl/resourcegroup/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,13 @@ func NewGroupFromOptions(groupName string, options *model.ResourceGroupSettings)
Name: groupName,
}
var isRUMode bool
if options.RRURate > 0 || options.WRURate > 0 {
if options.RURate > 0 {
isRUMode = true
group.Mode = rmpb.GroupMode_RUMode
group.RUSettings = &rmpb.GroupRequestUnitSettings{
RRU: &rmpb.TokenBucket{
RU: &rmpb.TokenBucket{
Settings: &rmpb.TokenLimitSettings{
FillRate: options.RRURate,
},
},
WRU: &rmpb.TokenBucket{
Settings: &rmpb.TokenLimitSettings{
FillRate: options.WRURate,
FillRate: options.RURate,
},
},
}
Expand Down
30 changes: 6 additions & 24 deletions ddl/resourcegroup/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,45 +48,27 @@ func TestNewResourceGroupFromOptions(t *testing.T) {
tests = append(tests, TestCase{
name: "normal case: ru case 1",
input: &model.ResourceGroupSettings{
RRURate: 2000,
WRURate: 20000,
RURate: 2000,
},
output: &rmpb.ResourceGroup{
Name: groupName,
Mode: rmpb.GroupMode_RUMode,
RUSettings: &rmpb.GroupRequestUnitSettings{
RRU: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 2000}},
WRU: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 20000}},
RU: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 2000}},
},
},
})

tests = append(tests, TestCase{
name: "normal case: ru case 2",
input: &model.ResourceGroupSettings{
RRURate: 5000,
RURate: 5000,
},
output: &rmpb.ResourceGroup{
Name: groupName,
Mode: rmpb.GroupMode_RUMode,
RUSettings: &rmpb.GroupRequestUnitSettings{
RRU: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 5000}},
WRU: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 0}},
},
},
})

tests = append(tests, TestCase{
name: "normal case: ru case 3",
input: &model.ResourceGroupSettings{
WRURate: 15000,
},
output: &rmpb.ResourceGroup{
Name: groupName,
Mode: rmpb.GroupMode_RUMode,
RUSettings: &rmpb.GroupRequestUnitSettings{
RRU: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 0}},
WRU: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 15000}},
RU: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 5000}},
},
},
})
Expand Down Expand Up @@ -163,7 +145,7 @@ func TestNewResourceGroupFromOptions(t *testing.T) {
CPULimiter: "8",
IOReadBandwidth: "3000Mi",
IOWriteBandwidth: "3000Mi",
RRURate: 1000,
RURate: 1000,
},
err: ErrInvalidResourceGroupDuplicatedMode,
})
Expand All @@ -175,7 +157,7 @@ func TestNewResourceGroupFromOptions(t *testing.T) {
CPULimiter: "8",
IOReadBandwidth: "3000Mi",
IOWriteBandwidth: "3000Mi",
RRURate: 1000,
RURate: 1000,
},
err: ErrTooLongResourceGroupName,
})
Expand Down
3 changes: 1 addition & 2 deletions executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3396,8 +3396,7 @@ func (e *memtableRetriever) setDataFromResourceGroups(sctx sessionctx.Context) e
row := types.MakeDatums(
group.ID,
group.Name.O,
group.RRURate,
group.WRURate,
group.RURate,
)
rows = append(rows, row)
}
Expand Down
2 changes: 1 addition & 1 deletion executor/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestUserAttributes(t *testing.T) {
rootTK.MustExec("alter user usr1 comment 'comment1'")
rootTK.MustQuery("select user_attributes from mysql.user where user = 'usr1'").Check(testkit.Rows(`{"metadata": {"comment": "comment1"}, "resource_group": "default"}`))
rootTK.MustExec("set global tidb_enable_resource_control = 'on'")
rootTK.MustExec("CREATE RESOURCE GROUP rg1 rru_per_sec = 100 wru_per_sec = 200")
rootTK.MustExec("CREATE RESOURCE GROUP rg1 ru_per_sec = 100")
rootTK.MustExec("alter user usr1 resource group rg1")
rootTK.MustQuery("select user_attributes from mysql.user where user = 'usr1'").Check(testkit.Rows(`{"metadata": {"comment": "comment1"}, "resource_group": "rg1"}`))
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ require (
github.com/pingcap/errors v0.11.5-0.20221009092201-b66cddb77c32
github.com/pingcap/failpoint v0.0.0-20220423142525-ae43b7f4e5c3
github.com/pingcap/fn v0.0.0-20200306044125-d5540d389059
github.com/pingcap/kvproto v0.0.0-20230119031034-25f1909b7934
github.com/pingcap/kvproto v0.0.0-20230131104319-a7c51106dfe7
github.com/pingcap/log v1.1.1-0.20221116035753-734d527bc87c
github.com/pingcap/sysutil v0.0.0-20220114020952-ea68d2dbf5b4
github.com/pingcap/tidb/parser v0.0.0-20211011031125-9b13dc409c5e
Expand All @@ -93,7 +93,7 @@ require (
github.com/tdakkota/asciicheck v0.1.1
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
github.com/tikv/client-go/v2 v2.0.5-0.20230120021435-f89383775234
github.com/tikv/pd v1.1.0-beta.0.20230119114149-402c2bfee2f3
github.com/tikv/pd v1.1.0-beta.0.20230201064005-6ca9a3398f15
github.com/tikv/pd/client v0.0.0-20230119115149-5c518d079b93
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144
github.com/twmb/murmur3 v1.1.3
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1143,8 +1143,9 @@ github.com/pingcap/fn v0.0.0-20200306044125-d5540d389059/go.mod h1:fMRU1BA1y+r89
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w=
github.com/pingcap/kvproto v0.0.0-20230119031034-25f1909b7934 h1:LB+BrfyO5fsz5pwN3V4HvTrpZTAmsjB4VkCEBLbjYUw=
github.com/pingcap/kvproto v0.0.0-20230119031034-25f1909b7934/go.mod h1:+on3Lfk/fb1lXkud3XvskJumhSIEEgN2TTbMObUlrxE=
github.com/pingcap/kvproto v0.0.0-20230131104319-a7c51106dfe7 h1:oYUK4V5PMlyIooU/+pPkKrJ3vELwcuuCNyKKlqSQa5c=
github.com/pingcap/kvproto v0.0.0-20230131104319-a7c51106dfe7/go.mod h1:+on3Lfk/fb1lXkud3XvskJumhSIEEgN2TTbMObUlrxE=
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
Expand Down Expand Up @@ -1309,8 +1310,8 @@ github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a h1:J/YdBZ46WKpXsxsW
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a/go.mod h1:h4xBhSNtOeEosLJ4P7JyKXX7Cabg7AVkWCK5gV2vOrM=
github.com/tikv/client-go/v2 v2.0.5-0.20230120021435-f89383775234 h1:2BmijiUk1Hcv0z58DVk4ypwaNmgutzLc2YJm0SHPEWE=
github.com/tikv/client-go/v2 v2.0.5-0.20230120021435-f89383775234/go.mod h1:jc7J2EbNeVvU6eXmB50wAGrTPyJwdi+0ENccMXMFSpw=
github.com/tikv/pd v1.1.0-beta.0.20230119114149-402c2bfee2f3 h1:cj3bhdIBJcLL2304EDEmd3eX+r73+hbGSYRFn/APiDU=
github.com/tikv/pd v1.1.0-beta.0.20230119114149-402c2bfee2f3/go.mod h1:IFQZ85uu1438yp7Tb0xCgvw/BdSPReB9zcJsxXbyTP4=
github.com/tikv/pd v1.1.0-beta.0.20230201064005-6ca9a3398f15 h1:ef+kODGby/rmF9fabJzqRM15NcGufkTRftROdy7jvAk=
github.com/tikv/pd v1.1.0-beta.0.20230201064005-6ca9a3398f15/go.mod h1:UnfZJ+ykNsVbQgo/CZ3NFyHnLJ/pQGlBD0M/WgxFHMQ=
github.com/tikv/pd/client v0.0.0-20230119115149-5c518d079b93 h1:KK5bx0KLcpYUCnuQ06THPYT6QdAMfvwAtRQ0saVGD7k=
github.com/tikv/pd/client v0.0.0-20230119115149-5c518d079b93/go.mod h1:NrbwVp9afaCmJjJEwFNtEQWfCChAW1ndnwjteHHS+d0=
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 h1:kl4KhGNsJIbDHS9/4U9yQo1UcPQM0kOMJHn29EoH/Ro=
Expand Down
3 changes: 1 addition & 2 deletions infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -1593,8 +1593,7 @@ var tableMemoryUsageOpsHistoryCols = []columnInfo{
var tableResourceGroupsCols = []columnInfo{
{name: "GROUP_ID", tp: mysql.TypeLonglong, size: 64, flag: mysql.NotNullFlag},
{name: "GROUP_NAME", tp: mysql.TypeVarchar, size: 512, flag: mysql.NotNullFlag},
{name: "RRU_PER_SECOND", tp: mysql.TypeLonglong, size: 64},
{name: "WRU_PER_SECOND", tp: mysql.TypeLonglong, size: 64},
{name: "RU_PER_SECOND", tp: mysql.TypeLonglong, size: 64},
// {name: "BURSTABLE", tp: mysql.TypeVarchar, size: 10},
}

Expand Down
14 changes: 5 additions & 9 deletions parser/ast/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2108,9 +2108,9 @@ type ResourceGroupOption struct {
type ResourceUnitType int

const (
ResourceRRURate ResourceUnitType = iota
ResourceWRURate
// Native mode
// RU mode
ResourceRURate ResourceUnitType = iota
// Raw mode
ResourceUnitCPU
ResourceUnitIOReadBandwidth
ResourceUnitIOWriteBandwidth
Expand All @@ -2122,12 +2122,8 @@ func (n *ResourceGroupOption) Restore(ctx *format.RestoreCtx) error {
}
fn := func() error {
switch n.Tp {
case ResourceRRURate:
ctx.WriteKeyWord("RRU_PER_SEC ")
ctx.WritePlain("= ")
ctx.WritePlainf("%d", n.UintValue)
case ResourceWRURate:
ctx.WriteKeyWord("WRU_PER_SEC ")
case ResourceRURate:
ctx.WriteKeyWord("RU_PER_SEC ")
ctx.WritePlain("= ")
ctx.WritePlainf("%d", n.UintValue)
case ResourceUnitCPU:
Expand Down
3 changes: 1 addition & 2 deletions parser/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ var tokenMap = map[string]int{
"INVISIBLE": invisible,
"INVOKER": invoker,
"IO": io,
"RRU_PER_SEC": rruRate,
"WRU_PER_SEC": wruRate,
"RU_PER_SEC": ruRate,
"IO_READ_BANDWIDTH": ioReadBandwidth,
"IO_WRITE_BANDWIDTH": ioWriteBandwidth,
"IPC": ipc,
Expand Down
10 changes: 3 additions & 7 deletions parser/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -1846,20 +1846,16 @@ type ResourceGroupRefInfo struct {

// ResourceGroupSettings is the settings of the resource group
type ResourceGroupSettings struct {
RRURate uint64 `json:"rru_per_sec"`
WRURate uint64 `json:"wru_per_sec"`
RURate uint64 `json:"ru_per_sec"`
CPULimiter string `json:"cpu_limit"`
IOReadBandwidth string `json:"io_read_bandwidth"`
IOWriteBandwidth string `json:"io_write_bandwidth"`
}

func (p *ResourceGroupSettings) String() string {
sb := new(strings.Builder)
if p.RRURate != 0 {
writeSettingIntegerToBuilder(sb, "RRU_PER_SEC", p.RRURate)
}
if p.WRURate != 0 {
writeSettingIntegerToBuilder(sb, "WRU_PER_SEC", p.WRURate)
if p.RURate != 0 {
writeSettingIntegerToBuilder(sb, "RU_PER_SEC", p.RURate)
}
if len(p.CPULimiter) > 0 {
writeSettingStringToBuilder(sb, "CPU", p.CPULimiter)
Expand Down
Loading