diff --git a/client/go.mod b/client/go.mod index 320c8cad9dd..3675df6bb92 100644 --- a/client/go.mod +++ b/client/go.mod @@ -7,7 +7,7 @@ require ( github.com/opentracing/opentracing-go v1.2.0 github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00 - 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.20221110025148-ca232912c9f3 github.com/prometheus/client_golang v1.11.0 github.com/stretchr/testify v1.8.1 diff --git a/client/go.sum b/client/go.sum index 0156bfe1b21..a7355525135 100644 --- a/client/go.sum +++ b/client/go.sum @@ -561,8 +561,8 @@ github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c h1:xpW9bvK+HuuTm github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c/go.mod h1:X2r9ueLEUZgtx2cIogM0v4Zj5uvvzhuuiu7Pn8HzMPg= github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00 h1:C3N3itkduZXDZFh4N3vQ5HEtld3S+Y+StULhWVvumU0= github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00/go.mod h1:4qGtCB0QK0wBzKtFEGDhxXnSnbQApw1gc9siScUl8ew= -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 v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8IDP+SZrdhV1Kibl9KrHxJ9eciw= github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/go.mod b/go.mod index 78fb3575a20..4088a6693d8 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/pingcap/errcode v0.3.0 github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c github.com/pingcap/failpoint v0.0.0-20200702092429-9f69995143ce - 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.20221110025148-ca232912c9f3 github.com/pingcap/sysutil v0.0.0-20211208032423-041a72e5860d github.com/pingcap/tidb-dashboard v0.0.0-20221201151320-ea3ee6971f2e diff --git a/go.sum b/go.sum index fd220038863..b59ff20efc9 100644 --- a/go.sum +++ b/go.sum @@ -368,8 +368,8 @@ github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c/go.mod h1:X2r9ue github.com/pingcap/failpoint v0.0.0-20200702092429-9f69995143ce h1:Y1kCxlCtlPTMtVcOkjUcuQKh+YrluSo7+7YMCQSzy30= github.com/pingcap/failpoint v0.0.0-20200702092429-9f69995143ce/go.mod h1:w4PEZ5y16LeofeeGwdgZB4ddv9bLyDuIX+ljstgKZyk= 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.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8IDP+SZrdhV1Kibl9KrHxJ9eciw= diff --git a/pkg/mcs/resource_manager/client/client.go b/pkg/mcs/resource_manager/client/client.go index 7592d82ad87..dde668bae62 100644 --- a/pkg/mcs/resource_manager/client/client.go +++ b/pkg/mcs/resource_manager/client/client.go @@ -437,7 +437,7 @@ func (gc *groupCostController) initRunState() { switch gc.mode { case rmpb.GroupMode_RUMode: gc.run.requestUnitTokens = make(map[rmpb.RequestUnitType]*tokenCounter) - for typ := range requestUnitList { + for typ := range requestUnitLimitTypeList { counter := &tokenCounter{ limiter: NewLimiter(now, 0, 0, initialRequestUnits, gc.lowRUNotifyChan), avgRUPerSec: initialRequestUnits / gc.run.targetPeriod.Seconds() * 2, @@ -447,7 +447,7 @@ func (gc *groupCostController) initRunState() { } case rmpb.GroupMode_RawMode: gc.run.resourceTokens = make(map[rmpb.RawResourceType]*tokenCounter) - for typ := range requestResourceList { + for typ := range requestResourceLimitTypeList { counter := &tokenCounter{ limiter: NewLimiter(now, 0, 0, initialRequestUnits, gc.lowRUNotifyChan), avgRUPerSec: initialRequestUnits / gc.run.targetPeriod.Seconds() * 2, @@ -586,13 +586,13 @@ func (gc *groupCostController) calcAvg(counter *tokenCounter, new float64) bool func (gc *groupCostController) shouldReportConsumption() bool { switch gc.Mode { case rmpb.GroupMode_RUMode: - for typ := range requestUnitList { + for typ := range requestUnitLimitTypeList { if getRUValueFromConsumption(gc.run.consumption, typ)-getRUValueFromConsumption(gc.run.lastRequestConsumption, typ) >= consumptionsReportingThreshold { return true } } case rmpb.GroupMode_RawMode: - for typ := range requestResourceList { + for typ := range requestResourceLimitTypeList { if getRawResourceValueFromConsumption(gc.run.consumption, typ)-getRawResourceValueFromConsumption(gc.run.lastRequestConsumption, typ) >= consumptionsReportingThreshold { return true } @@ -706,7 +706,7 @@ func (gc *groupCostController) collectRequestAndConsumption(low bool) *rmpb.Toke selected := !low switch gc.mode { case rmpb.GroupMode_RawMode: - requests := make([]*rmpb.RawResourceItem, 0, len(requestResourceList)) + requests := make([]*rmpb.RawResourceItem, 0, len(requestResourceLimitTypeList)) for typ, counter := range gc.run.resourceTokens { if low && counter.limiter.IsLowTokens() { selected = true @@ -723,7 +723,7 @@ func (gc *groupCostController) collectRequestAndConsumption(low bool) *rmpb.Toke }, } case rmpb.GroupMode_RUMode: - requests := make([]*rmpb.RequestUnitItem, 0, len(requestUnitList)) + requests := make([]*rmpb.RequestUnitItem, 0, len(requestUnitLimitTypeList)) for typ, counter := range gc.run.requestUnitTokens { if low && counter.limiter.IsLowTokens() { selected = true @@ -778,7 +778,7 @@ retryLoop: for i := 0; i < maxRetry; i++ { switch gc.mode { case rmpb.GroupMode_RawMode: - res := make([]*Reservation, 0, len(requestResourceList)) + res := make([]*Reservation, 0, len(requestResourceLimitTypeList)) for typ, counter := range gc.run.resourceTokens { if v := getRawResourceValueFromConsumption(delta, typ); v > 0 { res = append(res, counter.limiter.Reserve(ctx, defaultMaxWaitDuration, now, v)) @@ -788,7 +788,7 @@ retryLoop: break retryLoop } case rmpb.GroupMode_RUMode: - res := make([]*Reservation, 0, len(requestUnitList)) + res := make([]*Reservation, 0, len(requestUnitLimitTypeList)) for typ, counter := range gc.run.requestUnitTokens { if v := getRUValueFromConsumption(delta, typ); v > 0 { res = append(res, counter.limiter.Reserve(ctx, defaultMaxWaitDuration, now, v)) diff --git a/pkg/mcs/resource_manager/client/client_test.go b/pkg/mcs/resource_manager/client/client_test.go index dcfd06e114e..34cb34f29b5 100644 --- a/pkg/mcs/resource_manager/client/client_test.go +++ b/pkg/mcs/resource_manager/client/client_test.go @@ -32,7 +32,7 @@ func TestGroupControlBurstable(t *testing.T) { Name: "test", Mode: rmpb.GroupMode_RUMode, RUSettings: &rmpb.GroupRequestUnitSettings{ - RRU: &rmpb.TokenBucket{ + RU: &rmpb.TokenBucket{ Settings: &rmpb.TokenLimitSettings{ FillRate: 1000, }, diff --git a/pkg/mcs/resource_manager/client/config.go b/pkg/mcs/resource_manager/client/config.go index f6934f9a7ab..efe6fd77e53 100644 --- a/pkg/mcs/resource_manager/client/config.go +++ b/pkg/mcs/resource_manager/client/config.go @@ -21,11 +21,10 @@ import ( ) var ( - requestUnitList map[rmpb.RequestUnitType]struct{} = map[rmpb.RequestUnitType]struct{}{ - rmpb.RequestUnitType_RRU: {}, - rmpb.RequestUnitType_WRU: {}, + requestUnitLimitTypeList map[rmpb.RequestUnitType]struct{} = map[rmpb.RequestUnitType]struct{}{ + rmpb.RequestUnitType_RU: {}, } - requestResourceList map[rmpb.RawResourceType]struct{} = map[rmpb.RawResourceType]struct{}{ + requestResourceLimitTypeList map[rmpb.RawResourceType]struct{} = map[rmpb.RawResourceType]struct{}{ rmpb.RawResourceType_IOReadFlow: {}, rmpb.RawResourceType_IOWriteFlow: {}, rmpb.RawResourceType_CPU: {}, diff --git a/pkg/mcs/resource_manager/client/model.go b/pkg/mcs/resource_manager/client/model.go index 918cb31ca6c..06d2b13f676 100644 --- a/pkg/mcs/resource_manager/client/model.go +++ b/pkg/mcs/resource_manager/client/model.go @@ -122,11 +122,8 @@ func (dsc *SQLCalculator) AfterKVRequest(consumption *rmpb.Consumption, req Requ } func getRUValueFromConsumption(custom *rmpb.Consumption, typ rmpb.RequestUnitType) float64 { - switch typ { - case 0: - return custom.RRU - case 1: - return custom.WRU + if typ == 0 { + return custom.RRU + custom.WRU } return 0 } diff --git a/pkg/mcs/resource_manager/server/grpc_service.go b/pkg/mcs/resource_manager/server/grpc_service.go index c2b9625ec12..3d34314bf75 100644 --- a/pkg/mcs/resource_manager/server/grpc_service.go +++ b/pkg/mcs/resource_manager/server/grpc_service.go @@ -165,11 +165,8 @@ func (s *Service) AcquireTokenBuckets(stream rmpb.ResourceManager_AcquireTokenBu case rmpb.GroupMode_RUMode: var tokens *rmpb.GrantedRUTokenBucket for _, re := range req.GetRuItems().GetRequestRU() { - switch re.Type { - case rmpb.RequestUnitType_RRU: - tokens = rg.RequestRRU(now, re.Value, targetPeriodMs) - case rmpb.RequestUnitType_WRU: - tokens = rg.RequestWRU(now, re.Value, targetPeriodMs) + if re.Type == rmpb.RequestUnitType_RU { + tokens = rg.RequestRU(now, re.Value, targetPeriodMs) } resp.GrantedRUTokens = append(resp.GrantedRUTokens, tokens) } diff --git a/pkg/mcs/resource_manager/server/resource_group.go b/pkg/mcs/resource_manager/server/resource_group.go index 22ca1c4db86..5fc7aa7548a 100644 --- a/pkg/mcs/resource_manager/server/resource_group.go +++ b/pkg/mcs/resource_manager/server/resource_group.go @@ -40,8 +40,7 @@ type ResourceGroup struct { // RequestUnitSettings is the definition of the RU settings. type RequestUnitSettings struct { - RRU GroupTokenBucket `json:"rru,omitempty"` - WRU GroupTokenBucket `json:"wru,omitempty"` + RU GroupTokenBucket `json:"ru,omitempty"` } // RawResourceSettings is the definition of the native resource settings. @@ -119,8 +118,7 @@ func (rg *ResourceGroup) PatchSettings(metaGroup *rmpb.ResourceGroup) error { if metaGroup.GetRUSettings() == nil { return errors.New("invalid resource group settings, RU mode should set RU settings") } - rg.RUSettings.RRU.patch(metaGroup.GetRUSettings().GetRRU()) - rg.RUSettings.WRU.patch(metaGroup.GetRUSettings().GetWRU()) + rg.RUSettings.RU.patch(metaGroup.GetRUSettings().GetRU()) case rmpb.GroupMode_RawMode: if metaGroup.GetRawResourceSettings() == nil { return errors.New("invalid resource group settings, raw mode should set resource settings") @@ -148,8 +146,7 @@ func FromProtoResourceGroup(group *rmpb.ResourceGroup) *ResourceGroup { case rmpb.GroupMode_RUMode: if settings := group.GetRUSettings(); settings != nil { ruSettings = &RequestUnitSettings{ - RRU: NewGroupTokenBucket(settings.GetRRU()), - WRU: NewGroupTokenBucket(settings.GetWRU()), + RU: NewGroupTokenBucket(settings.GetRU()), } rg.RUSettings = ruSettings } @@ -166,26 +163,15 @@ func FromProtoResourceGroup(group *rmpb.ResourceGroup) *ResourceGroup { return rg } -// RequestRRU requests the RRU of the resource group. -func (rg *ResourceGroup) RequestRRU(now time.Time, neededTokens float64, targetPeriodMs uint64) *rmpb.GrantedRUTokenBucket { +// RequestRU requests the RU of the resource group. +func (rg *ResourceGroup) RequestRU(now time.Time, neededTokens float64, targetPeriodMs uint64) *rmpb.GrantedRUTokenBucket { rg.Lock() defer rg.Unlock() if rg.RUSettings == nil { return nil } - tb, trickleTimeMs := rg.RUSettings.RRU.request(now, neededTokens, targetPeriodMs) - return &rmpb.GrantedRUTokenBucket{Type: rmpb.RequestUnitType_RRU, GrantedTokens: tb, TrickleTimeMs: trickleTimeMs} -} - -// RequestWRU requests the WRU of the resource group. -func (rg *ResourceGroup) RequestWRU(now time.Time, neededTokens float64, targetPeriodMs uint64) *rmpb.GrantedRUTokenBucket { - rg.Lock() - defer rg.Unlock() - if rg.RUSettings == nil { - return nil - } - tb, trickleTimeMs := rg.RUSettings.WRU.request(now, neededTokens, targetPeriodMs) - return &rmpb.GrantedRUTokenBucket{Type: rmpb.RequestUnitType_WRU, GrantedTokens: tb, TrickleTimeMs: trickleTimeMs} + tb, trickleTimeMs := rg.RUSettings.RU.request(now, neededTokens, targetPeriodMs) + return &rmpb.GrantedRUTokenBucket{GrantedTokens: tb, TrickleTimeMs: trickleTimeMs} } // IntoProtoResourceGroup converts a ResourceGroup to a rmpb.ResourceGroup. @@ -198,8 +184,7 @@ func (rg *ResourceGroup) IntoProtoResourceGroup() *rmpb.ResourceGroup { Name: rg.Name, Mode: rmpb.GroupMode_RUMode, RUSettings: &rmpb.GroupRequestUnitSettings{ - RRU: rg.RUSettings.RRU.TokenBucket, - WRU: rg.RUSettings.WRU.TokenBucket, + RU: rg.RUSettings.RU.TokenBucket, }, } return group diff --git a/pkg/mcs/resource_manager/server/resource_group_test.go b/pkg/mcs/resource_manager/server/resource_group_test.go index 6e852ff65e3..29395afba5b 100644 --- a/pkg/mcs/resource_manager/server/resource_group_test.go +++ b/pkg/mcs/resource_manager/server/resource_group_test.go @@ -17,16 +17,10 @@ func TestPatchResourceGroup(t *testing.T) { patchJSONString string expectJSONString string }{ - {`{"name":"test", "mode":1, "r_u_settings": {"r_r_u":{"settings":{"fill_rate": 200000}}}}`, - `{"name":"test","mode":1,"r_u_settings":{"rru":{"token_bucket":{"settings":{"fill_rate":200000}},"initialized":false},"wru":{"initialized":false}}}`}, - {`{"name":"test", "mode":1, "r_u_settings": {"w_r_u":{"settings":{"fill_rate": 200000}}}}`, - `{"name":"test","mode":1,"r_u_settings":{"rru":{"initialized":false},"wru":{"token_bucket":{"settings":{"fill_rate":200000}},"initialized":false}}}`}, - {`{"name":"test", "mode":1, "r_u_settings": {"w_r_u":{"settings":{"fill_rate": 200000, "burst": 100000}}}}`, - `{"name":"test","mode":1,"r_u_settings":{"rru":{"initialized":false},"wru":{"token_bucket":{"settings":{"fill_rate":200000}},"initialized":false}}}`}, - {`{"name":"test", "mode":1, "r_u_settings": {"r_r_u":{"settings":{"fill_rate": 200000, "burst": 100000}}}}`, - `{"name":"test","mode":1,"r_u_settings":{"rru":{"token_bucket":{"settings":{"fill_rate":200000}},"initialized":false},"wru":{"initialized":false}}}`}, - {`{"name":"test", "mode":1, "r_u_settings": {"r_r_u":{"settings":{"fill_rate": 200000, "burst": 100000}}, "w_r_u":{"settings":{"fill_rate": 200000}}}}`, - `{"name":"test","mode":1,"r_u_settings":{"rru":{"token_bucket":{"settings":{"fill_rate":200000}},"initialized":false},"wru":{"token_bucket":{"settings":{"fill_rate":200000}},"initialized":false}}}`}, + {`{"name":"test", "mode":1, "r_u_settings": {"r_u":{"settings":{"fill_rate": 200000}}}}`, + `{"name":"test","mode":1,"r_u_settings":{"ru":{"token_bucket":{"settings":{"fill_rate":200000}},"initialized":false}}}`}, + {`{"name":"test", "mode":1, "r_u_settings": {"r_u":{"settings":{"fill_rate": 200000, "burst": 100000}}}}`, + `{"name":"test","mode":1,"r_u_settings":{"ru":{"token_bucket":{"settings":{"fill_rate":200000}},"initialized":false}}}`}, } for _, ca := range testCaseRU { diff --git a/tests/client/go.mod b/tests/client/go.mod index d2e58cec21e..6e2fbe12404 100644 --- a/tests/client/go.mod +++ b/tests/client/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00 - 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.20221110025148-ca232912c9f3 github.com/stretchr/testify v1.8.1 github.com/tikv/pd v0.0.0-00010101000000-000000000000 diff --git a/tests/client/go.sum b/tests/client/go.sum index aa8890c181d..fddf2bd353f 100644 --- a/tests/client/go.sum +++ b/tests/client/go.sum @@ -789,8 +789,8 @@ github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c/go.mod h1:X2r9ue github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00 h1:C3N3itkduZXDZFh4N3vQ5HEtld3S+Y+StULhWVvumU0= github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00/go.mod h1:4qGtCB0QK0wBzKtFEGDhxXnSnbQApw1gc9siScUl8ew= 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.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8IDP+SZrdhV1Kibl9KrHxJ9eciw= diff --git a/tests/msc/go.mod b/tests/msc/go.mod index 55ab5995b54..6f482bd1128 100644 --- a/tests/msc/go.mod +++ b/tests/msc/go.mod @@ -3,7 +3,7 @@ module github.com/tikv/pd/tests/msc go 1.19 require ( - github.com/pingcap/kvproto v0.0.0-20230119031034-25f1909b7934 + github.com/pingcap/kvproto v0.0.0-20230131104319-a7c51106dfe7 github.com/stretchr/testify v1.8.1 github.com/tikv/pd v0.0.0-00010101000000-000000000000 github.com/tikv/pd/client v0.0.0-00010101000000-000000000000 @@ -89,7 +89,6 @@ require ( github.com/pelletier/go-toml/v2 v2.0.1 // indirect github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36 // indirect github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d // indirect - github.com/pingcap/check v0.0.0-20211026125417-57bd13f7b5f0 // indirect github.com/pingcap/errcode v0.3.0 // indirect github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c // indirect github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00 // indirect diff --git a/tests/msc/go.sum b/tests/msc/go.sum index 8db354013f3..86240e465bb 100644 --- a/tests/msc/go.sum +++ b/tests/msc/go.sum @@ -779,8 +779,7 @@ github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d h1:U+PMnTlV2tu7RuMK5e github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d/go.mod h1:lXfE4PvvTW5xOjO6Mba8zDPyw8M93B6AQ7frTGnMlA8= github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8/go.mod h1:B1+S9LNcuMyLH/4HMTViQOJevkGiik3wW2AN9zb2fNQ= github.com/pingcap/check v0.0.0-20191107115940-caf2b9e6ccf4/go.mod h1:PYMCGwN0JHjoqGr3HrZoD+b8Tgx8bKnArhSq8YVzUMc= -github.com/pingcap/check v0.0.0-20211026125417-57bd13f7b5f0 h1:HVl5539r48eA+uDuX/ziBmQCxzT1pGrzWbKuXT46Bq0= -github.com/pingcap/check v0.0.0-20211026125417-57bd13f7b5f0/go.mod h1:PYMCGwN0JHjoqGr3HrZoD+b8Tgx8bKnArhSq8YVzUMc= +github.com/pingcap/check v0.0.0-20191216031241-8a5a85928f12 h1:rfD9v3+ppLPzoQBgZev0qYCpegrwyFx/BUpkApEiKdY= github.com/pingcap/errcode v0.3.0 h1:IF6LC/4+b1KNwrMlr2rBTUrojFPMexXBcDWZSpNwxjg= github.com/pingcap/errcode v0.3.0/go.mod h1:4b2X8xSqxIroj/IZ9MX/VGZhAwc11wB9wRIzHvz6SeM= github.com/pingcap/errors v0.11.0/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= @@ -791,8 +790,8 @@ github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c/go.mod h1:X2r9ue github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00 h1:C3N3itkduZXDZFh4N3vQ5HEtld3S+Y+StULhWVvumU0= github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00/go.mod h1:4qGtCB0QK0wBzKtFEGDhxXnSnbQApw1gc9siScUl8ew= 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.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8IDP+SZrdhV1Kibl9KrHxJ9eciw= diff --git a/tests/msc/resource_manager/resource_manager_test.go b/tests/msc/resource_manager/resource_manager_test.go index 1fcea64ead9..8730a9370fc 100644 --- a/tests/msc/resource_manager/resource_manager_test.go +++ b/tests/msc/resource_manager/resource_manager_test.go @@ -75,38 +75,25 @@ func (suite *resourceManagerClientTestSuite) SetupSuite() { Name: "test1", Mode: rmpb.GroupMode_RUMode, RUSettings: &rmpb.GroupRequestUnitSettings{ - RRU: &rmpb.TokenBucket{ + RU: &rmpb.TokenBucket{ Settings: &rmpb.TokenLimitSettings{ FillRate: 10000, }, Tokens: 100000, }, - WRU: &rmpb.TokenBucket{ - Settings: &rmpb.TokenLimitSettings{ - FillRate: 20000, - }, - Tokens: 50000, - }, }, }, { Name: "test2", Mode: rmpb.GroupMode_RUMode, RUSettings: &rmpb.GroupRequestUnitSettings{ - RRU: &rmpb.TokenBucket{ + RU: &rmpb.TokenBucket{ Settings: &rmpb.TokenLimitSettings{ FillRate: 40000, BurstLimit: -1, }, Tokens: 100000, }, - WRU: &rmpb.TokenBucket{ - Settings: &rmpb.TokenLimitSettings{ - FillRate: 20000, - BurstLimit: -1, - }, - Tokens: 50000, - }, }, }, } @@ -127,7 +114,7 @@ func (suite *resourceManagerClientTestSuite) TestWatchResourceGroup() { Name: "test", Mode: rmpb.GroupMode_RUMode, RUSettings: &rmpb.GroupRequestUnitSettings{ - RRU: &rmpb.TokenBucket{ + RU: &rmpb.TokenBucket{ Settings: &rmpb.TokenLimitSettings{ FillRate: 10000, }, @@ -159,7 +146,7 @@ func (suite *resourceManagerClientTestSuite) TestWatchResourceGroup() { // Mock modify resource groups modifySettings := func(gs *rmpb.ResourceGroup) { gs.RUSettings = &rmpb.GroupRequestUnitSettings{ - RRU: &rmpb.TokenBucket{ + RU: &rmpb.TokenBucket{ Settings: &rmpb.TokenLimitSettings{ FillRate: 20000, }, @@ -188,12 +175,12 @@ func (suite *resourceManagerClientTestSuite) TestWatchResourceGroup() { case res := <-watchChan: if i < 6 { for _, r := range res { - suite.Equal(uint64(10000), r.RUSettings.RRU.Settings.FillRate) + suite.Equal(uint64(10000), r.RUSettings.RU.Settings.FillRate) i++ } } else { // after modify for _, r := range res { - suite.Equal(uint64(20000), r.RUSettings.RRU.Settings.FillRate) + suite.Equal(uint64(20000), r.RUSettings.RU.Settings.FillRate) i++ } } @@ -294,14 +281,14 @@ func (suite *resourceManagerClientTestSuite) TestResourceGroupController() { resourceGroupName: suite.initGroups[0].Name, len: 8, tcs: []tokenConsumptionPerSecond{ - {rruTokensAtATime: 50, wruTokensAtATime: 20, times: 200, waitDuration: 0}, - {rruTokensAtATime: 50, wruTokensAtATime: 100, times: 200, waitDuration: 0}, - {rruTokensAtATime: 50, wruTokensAtATime: 100, times: 200, waitDuration: 0}, - {rruTokensAtATime: 20, wruTokensAtATime: 40, times: 500, waitDuration: 0}, - {rruTokensAtATime: 25, wruTokensAtATime: 50, times: 400, waitDuration: 0}, - {rruTokensAtATime: 30, wruTokensAtATime: 60, times: 330, waitDuration: 0}, - {rruTokensAtATime: 40, wruTokensAtATime: 80, times: 250, waitDuration: 0}, - {rruTokensAtATime: 50, wruTokensAtATime: 100, times: 200, waitDuration: 0}, + {rruTokensAtATime: 50, wruTokensAtATime: 20, times: 100, waitDuration: 0}, + {rruTokensAtATime: 50, wruTokensAtATime: 100, times: 100, waitDuration: 0}, + {rruTokensAtATime: 50, wruTokensAtATime: 100, times: 100, waitDuration: 0}, + {rruTokensAtATime: 20, wruTokensAtATime: 40, times: 250, waitDuration: 0}, + {rruTokensAtATime: 25, wruTokensAtATime: 50, times: 200, waitDuration: 0}, + {rruTokensAtATime: 30, wruTokensAtATime: 60, times: 165, waitDuration: 0}, + {rruTokensAtATime: 40, wruTokensAtATime: 80, times: 125, waitDuration: 0}, + {rruTokensAtATime: 50, wruTokensAtATime: 100, times: 100, waitDuration: 0}, }, }, } @@ -366,7 +353,7 @@ func (suite *resourceManagerClientTestSuite) TestAcquireTokenBucket() { for _, group := range groups { requests := make([]*rmpb.RequestUnitItem, 0) requests = append(requests, &rmpb.RequestUnitItem{ - Type: rmpb.RequestUnitType_RRU, + Type: rmpb.RequestUnitType_RU, Value: 100, }) req := &rmpb.TokenBucketRequest{ @@ -390,15 +377,14 @@ func (suite *resourceManagerClientTestSuite) TestAcquireTokenBucket() { } gresp, err := cli.GetResourceGroup(suite.ctx, groups[0].GetName()) re.NoError(err) - re.Less(gresp.RUSettings.RRU.Tokens, groups[0].RUSettings.RRU.Tokens) + re.Less(gresp.RUSettings.RU.Tokens, groups[0].RUSettings.RU.Tokens) checkFunc := func(g1 *rmpb.ResourceGroup, g2 *rmpb.ResourceGroup) { re.Equal(g1.GetName(), g2.GetName()) re.Equal(g1.GetMode(), g2.GetMode()) - re.Equal(g1.GetRUSettings().RRU.Settings.FillRate, g2.GetRUSettings().RRU.Settings.FillRate) - re.Equal(g1.GetRUSettings().RRU.Settings.BurstLimit, g2.GetRUSettings().RRU.Settings.BurstLimit) + re.Equal(g1.GetRUSettings().RU.Settings.FillRate, g2.GetRUSettings().RU.Settings.FillRate) // now we don't persistent tokens in running state, so tokens is original. - re.Equal(g1.GetRUSettings().RRU.Tokens, g2.GetRUSettings().RRU.Tokens) + re.Equal(g1.GetRUSettings().RU.Tokens, g2.GetRUSettings().RU.Tokens) re.NoError(err) } @@ -436,10 +422,10 @@ func (suite *resourceManagerClientTestSuite) TestBasicResourceGroupCURD() { modifySettings func(*rmpb.ResourceGroup) }{ {"test1", rmpb.GroupMode_RUMode, true, true, - `{"name":"test1","mode":1,"r_u_settings":{"rru":{"token_bucket":{"settings":{"fill_rate":10000}},"initialized":false},"wru":{"initialized":false}}}`, + `{"name":"test1","mode":1,"r_u_settings":{"ru":{"token_bucket":{"settings":{"fill_rate":10000}},"initialized":false}}}`, func(gs *rmpb.ResourceGroup) { gs.RUSettings = &rmpb.GroupRequestUnitSettings{ - RRU: &rmpb.TokenBucket{ + RU: &rmpb.TokenBucket{ Settings: &rmpb.TokenLimitSettings{ FillRate: 10000, }, @@ -449,10 +435,10 @@ func (suite *resourceManagerClientTestSuite) TestBasicResourceGroupCURD() { }, {"test2", rmpb.GroupMode_RUMode, true, true, - `{"name":"test2","mode":1,"r_u_settings":{"rru":{"token_bucket":{"settings":{"fill_rate":20000}},"initialized":false},"wru":{"initialized":false}}}`, + `{"name":"test2","mode":1,"r_u_settings":{"ru":{"token_bucket":{"settings":{"fill_rate":20000}},"initialized":false}}}`, func(gs *rmpb.ResourceGroup) { gs.RUSettings = &rmpb.GroupRequestUnitSettings{ - RRU: &rmpb.TokenBucket{ + RU: &rmpb.TokenBucket{ Settings: &rmpb.TokenLimitSettings{ FillRate: 20000, }, @@ -461,10 +447,10 @@ func (suite *resourceManagerClientTestSuite) TestBasicResourceGroupCURD() { }, }, {"test2", rmpb.GroupMode_RUMode, false, true, - `{"name":"test2","mode":1,"r_u_settings":{"rru":{"token_bucket":{"settings":{"fill_rate":30000}},"initialized":false},"wru":{"initialized":false}}}`, + `{"name":"test2","mode":1,"r_u_settings":{"ru":{"token_bucket":{"settings":{"fill_rate":30000}},"initialized":false}}}`, func(gs *rmpb.ResourceGroup) { gs.RUSettings = &rmpb.GroupRequestUnitSettings{ - RRU: &rmpb.TokenBucket{ + RU: &rmpb.TokenBucket{ Settings: &rmpb.TokenLimitSettings{ FillRate: 30000, }, @@ -476,7 +462,7 @@ func (suite *resourceManagerClientTestSuite) TestBasicResourceGroupCURD() { `{"name":"test3","mode":2}`, func(gs *rmpb.ResourceGroup) { gs.RUSettings = &rmpb.GroupRequestUnitSettings{ - RRU: &rmpb.TokenBucket{ + RU: &rmpb.TokenBucket{ Settings: &rmpb.TokenLimitSettings{ FillRate: 10000, }, diff --git a/tools/pd-tso-bench/go.sum b/tools/pd-tso-bench/go.sum index ad620659cbf..a9c358ad49a 100644 --- a/tools/pd-tso-bench/go.sum +++ b/tools/pd-tso-bench/go.sum @@ -561,8 +561,8 @@ github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c h1:xpW9bvK+HuuTm github.com/pingcap/errors v0.11.5-0.20211224045212-9687c2b0f87c/go.mod h1:X2r9ueLEUZgtx2cIogM0v4Zj5uvvzhuuiu7Pn8HzMPg= github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00 h1:C3N3itkduZXDZFh4N3vQ5HEtld3S+Y+StULhWVvumU0= github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00/go.mod h1:4qGtCB0QK0wBzKtFEGDhxXnSnbQApw1gc9siScUl8ew= -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 v1.1.1-0.20221110025148-ca232912c9f3 h1:HR/ylkkLmGdSSDaD8IDP+SZrdhV1Kibl9KrHxJ9eciw= github.com/pingcap/log v1.1.1-0.20221110025148-ca232912c9f3/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=