Skip to content

Commit

Permalink
*: Setup Global Resource Controller
Browse files Browse the repository at this point in the history
Signed-off-by: nolouch <nolouch@gmail.com>
  • Loading branch information
nolouch committed Jan 20, 2023
1 parent efbdeed commit 2400de3
Show file tree
Hide file tree
Showing 15 changed files with 611 additions and 76 deletions.
2 changes: 1 addition & 1 deletion ddl/resourcegroup/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewGroupFromOptions(groupName string, options *model.ResourceGroupSettings)
}

group.Mode = rmpb.GroupMode_RawMode
group.ResourceSettings = &rmpb.GroupResourceSettings{
group.RawResourceSettings = &rmpb.GroupRawResourceSettings{
Cpu: &rmpb.TokenBucket{
Settings: &rmpb.TokenLimitSettings{
FillRate: cpuRate,
Expand Down
2 changes: 1 addition & 1 deletion domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ func (do *Domain) globalConfigSyncerKeeper() {
for {
select {
case entry := <-do.globalCfgSyncer.NotifyCh:
err := do.globalCfgSyncer.StoreGlobalConfig(context.Background(), entry)
err := do.globalCfgSyncer.StoreGlobalConfig(context.Background(), "/global/config/", entry)
if err != nil {
logutil.BgLogger().Error("global config syncer store failed", zap.Error(err))
}
Expand Down
12 changes: 12 additions & 0 deletions domain/domain_sysvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func (do *Domain) initDomainSysVars() {

variable.SetExternalTimestamp = do.setExternalTimestamp
variable.GetExternalTimestamp = do.getExternalTimestamp

setGlobalResourceControlFunc := do.setGlobalResourceControl
variable.SetGlobalResourceControl.Store(&setGlobalResourceControlFunc)
}

// setStatsCacheCapacity sets statsCache cap
Expand Down Expand Up @@ -67,6 +70,15 @@ func (do *Domain) setPDClientDynamicOption(name, sVal string) {
}
}

func (do *Domain) setGlobalResourceControl(enable bool) {
if enable {
variable.EnableGlobalResourceControlFunc()
} else {
variable.DisableGlobalResourceControlFunc()
}
logutil.BgLogger().Info("set resource control", zap.Bool("enable", enable))
}

// updatePDClient is used to set the dynamic option into the PD client.
func (do *Domain) updatePDClient(option pd.DynamicOption, val interface{}) error {
store, ok := do.store.(interface{ GetPDClient() pd.Client })
Expand Down
6 changes: 3 additions & 3 deletions domain/globalconfigsync/globalconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ func NewGlobalConfigSyncer(p pd.Client) *GlobalConfigSyncer {
}

// StoreGlobalConfig is used to store global config.
func (s *GlobalConfigSyncer) StoreGlobalConfig(ctx context.Context, item pd.GlobalConfigItem) error {
func (s *GlobalConfigSyncer) StoreGlobalConfig(ctx context.Context, configPath string, item pd.GlobalConfigItem) error {
if s.pd == nil {
return nil
}
err := s.pd.StoreGlobalConfig(ctx, []pd.GlobalConfigItem{item})
err := s.pd.StoreGlobalConfig(ctx, configPath, []pd.GlobalConfigItem{item})
if err != nil {
return err
}
logutil.BgLogger().Info("store global config", zap.String("name", item.Name), zap.String("value", item.Value))
logutil.BgLogger().Info("store global config", zap.String("name", item.Name), zap.String("path", configPath), zap.String("value", item.Value))
return nil
}

Expand Down
37 changes: 22 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/pingcap/tidb
go 1.19

require (
cloud.google.com/go/storage v1.21.0
cloud.google.com/go/storage v1.27.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.2.0
Expand Down Expand Up @@ -70,7 +70,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-20230105060948-64890fa4f6c1
github.com/pingcap/kvproto v0.0.0-20230119031034-25f1909b7934
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 @@ -80,18 +80,19 @@ require (
github.com/prometheus/client_model v0.3.0
github.com/prometheus/common v0.39.0
github.com/prometheus/prometheus v0.0.0-20190525122359-d20e84d0fb64
github.com/sasha-s/go-deadlock v0.0.0-20161201235124-341000892f3d
github.com/sasha-s/go-deadlock v0.2.0
github.com/shirou/gopsutil/v3 v3.22.9
github.com/shurcooL/httpgzip v0.0.0-20190720172056-320755c1c1b0
github.com/soheilhy/cmux v0.1.5
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/stathat/consistent v1.0.0
github.com/stretchr/testify v1.8.0
github.com/stretchr/testify v1.8.1
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.20230112062023-fe5b35c5f5dc
github.com/tikv/pd/client v0.0.0-20221031025758-80f0d8ca4d07
github.com/tikv/pd v1.1.0-beta.0.20230118040950-082fc6a9bc2e
github.com/tikv/pd/client v0.0.0-20230118040950-082fc6a9bc2e
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144
github.com/twmb/murmur3 v1.1.3
github.com/uber/jaeger-client-go v2.22.1+incompatible
Expand All @@ -104,7 +105,7 @@ require (
go.etcd.io/etcd/client/v3 v3.5.2
go.etcd.io/etcd/server/v3 v3.5.2
go.etcd.io/etcd/tests/v3 v3.5.2
go.opencensus.io v0.23.0
go.opencensus.io v0.24.0
go.uber.org/atomic v1.10.0
go.uber.org/automaxprocs v1.4.0
go.uber.org/goleak v1.2.0
Expand All @@ -119,8 +120,8 @@ require (
golang.org/x/text v0.6.0
golang.org/x/time v0.3.0
golang.org/x/tools v0.2.0
google.golang.org/api v0.74.0
google.golang.org/grpc v1.45.0
google.golang.org/api v0.103.0
google.golang.org/grpc v1.51.0
gopkg.in/yaml.v2 v2.4.0
honnef.co/go/tools v0.3.3
k8s.io/apimachinery v0.26.0
Expand All @@ -129,9 +130,10 @@ require (
)

require (
cloud.google.com/go v0.100.2 // indirect
cloud.google.com/go/compute v1.5.0 // indirect
cloud.google.com/go/iam v0.1.1 // indirect
cloud.google.com/go v0.105.0 // indirect
cloud.google.com/go/compute v1.13.0 // indirect
cloud.google.com/go/compute/metadata v0.2.1 // indirect
cloud.google.com/go/iam v0.7.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect
Expand Down Expand Up @@ -167,7 +169,8 @@ require (
github.com/golang/glog v1.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/googleapis/gax-go/v2 v2.2.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
Expand Down Expand Up @@ -205,7 +208,7 @@ require (
github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/petermattis/goid v0.0.0-20170504144140-0ded85884ba5 // indirect
github.com/petermattis/goid v0.0.0-20211229010228-4d14c490ee36 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712 // indirect
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 // indirect
Expand Down Expand Up @@ -246,9 +249,9 @@ require (
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb // indirect
google.golang.org/genproto v0.0.0-20221202195650-67e5cbc046fd // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
Expand All @@ -262,3 +265,7 @@ replace (
github.com/pingcap/tidb/parser => ./parser
go.opencensus.io => go.opencensus.io v0.23.1-0.20220331163232-052120675fac
)

replace github.com/tikv/client-go/v2 => github.com/tidblabs/client-go/v2 v2.0.1-0.20230119094214-319f6b9df0e2

replace github.com/tikv/pd => github.com/CabinfeverB/pd v1.1.0-beta.0.20230119113201-91eb7b3474a4
Loading

0 comments on commit 2400de3

Please sign in to comment.