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

mockstore: update pd/client and client-go to repair kvproto compatibility #40597

Merged
merged 21 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from 19 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
1,431 changes: 1,367 additions & 64 deletions DEPS.bzl

Large diffs are not rendered by default.

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
4 changes: 2 additions & 2 deletions ddl/resourcegroup/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestNewResourceGroupFromOptions(t *testing.T) {
output: &rmpb.ResourceGroup{
Name: groupName,
Mode: rmpb.GroupMode_RawMode,
ResourceSettings: &rmpb.GroupResourceSettings{
RawResourceSettings: &rmpb.GroupRawResourceSettings{
Cpu: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 8000}},
IoRead: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 3000000000}},
IoWrite: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 1500000000}},
Expand All @@ -119,7 +119,7 @@ func TestNewResourceGroupFromOptions(t *testing.T) {
output: &rmpb.ResourceGroup{
Name: groupName,
Mode: rmpb.GroupMode_RawMode,
ResourceSettings: &rmpb.GroupResourceSettings{
RawResourceSettings: &rmpb.GroupRawResourceSettings{
Cpu: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 8000}},
IoRead: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 3145728000}},
IoWrite: &rmpb.TokenBucket{Settings: &rmpb.TokenLimitSettings{FillRate: 3145728000}},
Expand Down
1 change: 1 addition & 0 deletions domain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ go_library(
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_kvproto//pkg/metapb",
"@com_github_pingcap_kvproto//pkg/pdpb",
"@com_github_pingcap_log//:log",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//oracle",
Expand Down
3 changes: 2 additions & 1 deletion domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/log"
"github.com/pingcap/tidb/bindinfo"
"github.com/pingcap/tidb/br/pkg/streamhelper"
Expand Down Expand Up @@ -445,7 +446,7 @@ func (do *Domain) InfoSyncer() *infosync.InfoSyncer {

// NotifyGlobalConfigChange notify global config syncer to store the global config into PD.
func (do *Domain) NotifyGlobalConfigChange(name, value string) {
do.globalCfgSyncer.Notify(pd.GlobalConfigItem{Name: name, Value: value})
do.globalCfgSyncer.Notify(pd.GlobalConfigItem{Name: name, Value: value, EventType: pdpb.EventType_PUT})
}

// GetGlobalConfigSyncer exports for testing.
Expand Down
7 changes: 5 additions & 2 deletions domain/globalconfigsync/globalconfig.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 PingCAP, Inc.
// Copyright 2023 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,9 @@ import (
"go.uber.org/zap"
)

// GlobalConfigPath as Etcd prefix
const GlobalConfigPath = "/global/config/"

// GlobalConfigSyncer is used to sync pd global config.
type GlobalConfigSyncer struct {
pd pd.Client
Expand All @@ -41,7 +44,7 @@ func (s *GlobalConfigSyncer) StoreGlobalConfig(ctx context.Context, item pd.Glob
if s.pd == nil {
return nil
}
err := s.pd.StoreGlobalConfig(ctx, []pd.GlobalConfigItem{item})
err := s.pd.StoreGlobalConfig(ctx, GlobalConfigPath, []pd.GlobalConfigItem{item})
if err != nil {
return err
}
Expand Down
18 changes: 10 additions & 8 deletions domain/globalconfigsync/globalconfig_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 PingCAP, Inc.
// Copyright 2023 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@ package globalconfigsync_test

import (
"context"
"path"
"runtime"
"testing"
"time"
Expand Down Expand Up @@ -58,11 +59,12 @@ func TestGlobalConfigSyncer(t *testing.T) {
syncer.Notify(pd.GlobalConfigItem{Name: "a", Value: "b"})
err = syncer.StoreGlobalConfig(context.Background(), <-syncer.NotifyCh)
require.NoError(t, err)
items, err := client.LoadGlobalConfig(context.Background(), []string{"a"})
items, revision, err := client.LoadGlobalConfig(context.Background(), globalconfigsync.GlobalConfigPath)
require.NoError(t, err)
require.Equal(t, len(items), 1)
require.Equal(t, items[0].Name, "/global/config/a")
require.Equal(t, items[0].Value, "b")
require.Equal(t, 1, len(items))
require.Equal(t, path.Join(globalconfigsync.GlobalConfigPath, "a"), items[0].Name)
require.Equal(t, int64(0), revision)
require.Equal(t, "b", items[0].Value)
}

func TestStoreGlobalConfig(t *testing.T) {
Expand Down Expand Up @@ -95,15 +97,15 @@ func TestStoreGlobalConfig(t *testing.T) {
client :=
store.(kv.StorageWithPD).GetPDClient()
// enable top sql will be translated to enable_resource_metering
items, err := client.LoadGlobalConfig(context.Background(), []string{"enable_resource_metering", "source_id"})
items, _, err := client.LoadGlobalConfig(context.Background(), globalconfigsync.GlobalConfigPath)
require.NoError(t, err)
if len(items) == 2 && items[0].Value == "" {
continue
}
require.Len(t, items, 2)
require.Equal(t, items[0].Name, "/global/config/enable_resource_metering")
require.Equal(t, items[0].Name, path.Join(globalconfigsync.GlobalConfigPath, "enable_resource_metering"))
require.Equal(t, items[0].Value, "true")
require.Equal(t, items[1].Name, "/global/config/source_id")
require.Equal(t, items[1].Name, path.Join(globalconfigsync.GlobalConfigPath, "source_id"))
require.Equal(t, items[1].Value, "2")
return
}
Expand Down
35 changes: 19 additions & 16 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,18 @@ 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/client-go/v2 v2.0.5-0.20230120021435-f89383775234
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
github.com/uber/jaeger-client-go v2.22.1+incompatible
Expand All @@ -104,7 +104,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 +119,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 +129,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 +168,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 +207,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 All @@ -223,6 +225,7 @@ require (
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a // indirect
github.com/tikv/pd v1.1.0-beta.0.20230119114149-402c2bfee2f3 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
Expand All @@ -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 Down
Loading