From 25c5398d57ba593543e60737085ac00dc5531cef Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 17:49:20 +0800 Subject: [PATCH 01/16] server: enable deprecated linter for server Signed-off-by: Weizhen Wang --- build/nogo_config.json | 3 ++- server/plan_replayer.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build/nogo_config.json b/build/nogo_config.json index 97a1a1feed50e..15ca17ea9a485 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -769,7 +769,8 @@ "server/conn_test.go": "server/conn_test.go", "extension/": "extension code", "resourcemanager/": "resourcemanager code", - "keyspace/": "keyspace code" + "keyspace/": "keyspace code", + "server/": "server code" } }, "SA2000": { diff --git a/server/plan_replayer.go b/server/plan_replayer.go index 30f7c4ae821c1..d5265a21e7939 100644 --- a/server/plan_replayer.go +++ b/server/plan_replayer.go @@ -276,7 +276,7 @@ func loadSQLMetaFile(z *zip.Reader) (uint64, error) { } //nolint: errcheck,all_revive defer v.Close() - _, err = toml.DecodeReader(v, &varMap) + _, err = toml.NewDecoder(v).Decode(&varMap) if err != nil { return 0, errors.AddStack(err) } From 489f5a68b50ef57f47c1c3aaf632e930f66be51e Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 18:45:51 +0800 Subject: [PATCH 02/16] clean --- br/pkg/lightning/backend/local/local.go | 2 +- br/pkg/lightning/common/security.go | 2 +- br/pkg/restore/BUILD.bazel | 1 + br/pkg/restore/client.go | 2 +- br/pkg/restore/import.go | 3 ++- br/pkg/restore/split/BUILD.bazel | 1 + br/pkg/restore/split/client.go | 3 ++- br/pkg/utils/misc.go | 2 +- br/pkg/utils/store_manager.go | 2 +- executor/BUILD.bazel | 1 + executor/load_stats.go | 4 ++-- executor/lock_stats.go | 8 ++++---- executor/memtable_reader.go | 3 ++- infoschema/tables.go | 2 +- meta/autoid/BUILD.bazel | 1 + meta/autoid/autoid_service.go | 3 ++- util/topsql/reporter/single_target.go | 2 +- util/topsql/topsql_test.go | 4 ++-- 18 files changed, 27 insertions(+), 19 deletions(-) diff --git a/br/pkg/lightning/backend/local/local.go b/br/pkg/lightning/backend/local/local.go index 4f8ca6bf3117a..08a0bdca503c2 100644 --- a/br/pkg/lightning/backend/local/local.go +++ b/br/pkg/lightning/backend/local/local.go @@ -148,7 +148,7 @@ func (f *importClientFactoryImpl) makeConn(ctx context.Context, storeID uint64) if err != nil { return nil, errors.Trace(err) } - opt := grpc.WithInsecure() + opt := grpc.WithTransportCredentials(insecure.NewCredentials()) if f.tls.TLSConfig() != nil { opt = grpc.WithTransportCredentials(credentials.NewTLS(f.tls.TLSConfig())) } diff --git a/br/pkg/lightning/common/security.go b/br/pkg/lightning/common/security.go index a48abc48c2c54..753522be0cc50 100644 --- a/br/pkg/lightning/common/security.go +++ b/br/pkg/lightning/common/security.go @@ -104,7 +104,7 @@ func (tc *TLS) ToGRPCDialOption() grpc.DialOption { if tc.inner != nil { return grpc.WithTransportCredentials(credentials.NewTLS(tc.inner)) } - return grpc.WithInsecure() + return grpc.WithTransportCredentials(insecure.NewCredentials()) } // WrapListener places a TLS layer on top of the existing listener. diff --git a/br/pkg/restore/BUILD.bazel b/br/pkg/restore/BUILD.bazel index d4f70e278fd2c..35bed1951e9b3 100644 --- a/br/pkg/restore/BUILD.bazel +++ b/br/pkg/restore/BUILD.bazel @@ -88,6 +88,7 @@ go_library( "@org_golang_google_grpc//backoff", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//credentials", + "@org_golang_google_grpc//credentials/insecure", "@org_golang_google_grpc//keepalive", "@org_golang_google_grpc//status", "@org_golang_x_exp//slices", diff --git a/br/pkg/restore/client.go b/br/pkg/restore/client.go index c0f58817ec0af..dce80d0d91c26 100644 --- a/br/pkg/restore/client.go +++ b/br/pkg/restore/client.go @@ -1298,7 +1298,7 @@ func (rc *Client) switchTiKVMode(ctx context.Context, mode import_sstpb.SwitchMo finalStore := store rc.workerPool.ApplyOnErrorGroup(eg, func() error { - opt := grpc.WithInsecure() + opt := grpc.WithTransportCredentials(insecure.NewCredentials()) if rc.tlsConf != nil { opt = grpc.WithTransportCredentials(credentials.NewTLS(rc.tlsConf)) } diff --git a/br/pkg/restore/import.go b/br/pkg/restore/import.go index 5004639c1a00d..34da5cbea2404 100644 --- a/br/pkg/restore/import.go +++ b/br/pkg/restore/import.go @@ -38,6 +38,7 @@ import ( "google.golang.org/grpc/backoff" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/keepalive" "google.golang.org/grpc/status" ) @@ -197,7 +198,7 @@ func (ic *importClient) GetImportClient( if err != nil { return nil, errors.Trace(err) } - opt := grpc.WithInsecure() + opt := grpc.WithTransportCredentials(insecure.NewCredentials()) if ic.tlsConf != nil { opt = grpc.WithTransportCredentials(credentials.NewTLS(ic.tlsConf)) } diff --git a/br/pkg/restore/split/BUILD.bazel b/br/pkg/restore/split/BUILD.bazel index ac9eb50eb4d20..1726817092ba8 100644 --- a/br/pkg/restore/split/BUILD.bazel +++ b/br/pkg/restore/split/BUILD.bazel @@ -32,6 +32,7 @@ go_library( "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//credentials", + "@org_golang_google_grpc//credentials/insecure", "@org_golang_google_grpc//status", "@org_uber_go_multierr//:multierr", "@org_uber_go_zap//:zap", diff --git a/br/pkg/restore/split/client.go b/br/pkg/restore/split/client.go index fb82135ae2af6..b1151efd4d8b3 100644 --- a/br/pkg/restore/split/client.go +++ b/br/pkg/restore/split/client.go @@ -35,6 +35,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/status" ) @@ -336,7 +337,7 @@ func sendSplitRegionRequest(ctx context.Context, c *pdClient, regionInfo *Region if err != nil { return false, nil, err } - opt := grpc.WithInsecure() + opt := grpc.WithTransportCredentials(insecure.NewCredentials()) if c.tlsConf != nil { opt = grpc.WithTransportCredentials(credentials.NewTLS(c.tlsConf)) } diff --git a/br/pkg/utils/misc.go b/br/pkg/utils/misc.go index 8078802b2e055..d1d81d9df58af 100644 --- a/br/pkg/utils/misc.go +++ b/br/pkg/utils/misc.go @@ -84,7 +84,7 @@ func IsTypeCompatible(src types.FieldType, target types.FieldType) bool { } func GRPCConn(ctx context.Context, storeAddr string, tlsConf *tls.Config, opts ...grpc.DialOption) (*grpc.ClientConn, error) { - secureOpt := grpc.WithInsecure() + secureOpt := grpc.WithTransportCredentials(insecure.NewCredentials()) if tlsConf != nil { secureOpt = grpc.WithTransportCredentials(credentials.NewTLS(tlsConf)) } diff --git a/br/pkg/utils/store_manager.go b/br/pkg/utils/store_manager.go index 8dd50a2a57c82..96c65a3d72be1 100644 --- a/br/pkg/utils/store_manager.go +++ b/br/pkg/utils/store_manager.go @@ -136,7 +136,7 @@ func (mgr *StoreManager) getGrpcConnLocked(ctx context.Context, storeID uint64) if err != nil { return nil, errors.Trace(err) } - opt := grpc.WithInsecure() + opt := grpc.WithTransportCredentials(insecure.NewCredentials()) if mgr.tlsConf != nil { opt = grpc.WithTransportCredentials(credentials.NewTLS(mgr.tlsConf)) } diff --git a/executor/BUILD.bazel b/executor/BUILD.bazel index 35703034b1214..8b0e824288c99 100644 --- a/executor/BUILD.bazel +++ b/executor/BUILD.bazel @@ -239,6 +239,7 @@ go_library( "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//credentials", + "@org_golang_google_grpc//credentials/insecure", "@org_golang_google_grpc//status", "@org_golang_x_exp//slices", "@org_golang_x_sync//errgroup", diff --git a/executor/load_stats.go b/executor/load_stats.go index d59651e29200a..e292eb817519d 100644 --- a/executor/load_stats.go +++ b/executor/load_stats.go @@ -52,7 +52,7 @@ func (k loadStatsVarKeyType) String() string { const LoadStatsVarKey loadStatsVarKeyType = 0 // Next implements the Executor Next interface. -func (e *LoadStatsExec) Next(ctx context.Context, req *chunk.Chunk) error { +func (e *LoadStatsExec) Next(_ context.Context, req *chunk.Chunk) error { req.GrowAndReset(e.maxChunkSize) if len(e.info.Path) == 0 { return errors.New("Load Stats: file path is empty") @@ -72,7 +72,7 @@ func (e *LoadStatsExec) Close() error { } // Open implements the Executor Open interface. -func (e *LoadStatsExec) Open(ctx context.Context) error { +func (e *LoadStatsExec) Open(_ context.Context) error { return nil } diff --git a/executor/lock_stats.go b/executor/lock_stats.go index 540670e8119fc..ccf6df123db07 100644 --- a/executor/lock_stats.go +++ b/executor/lock_stats.go @@ -44,7 +44,7 @@ func (k lockStatsVarKeyType) String() string { const LockStatsVarKey lockStatsVarKeyType = 0 // Next implements the Executor Next interface. -func (e *LockStatsExec) Next(ctx context.Context, req *chunk.Chunk) error { +func (e *LockStatsExec) Next(_ context.Context, _ *chunk.Chunk) error { do := domain.GetDomain(e.ctx) is := do.InfoSchema() h := do.StatsHandle() @@ -87,7 +87,7 @@ func (e *LockStatsExec) Close() error { } // Open implements the Executor Open interface. -func (e *LockStatsExec) Open(ctx context.Context) error { +func (e *LockStatsExec) Open(_ context.Context) error { return nil } @@ -109,7 +109,7 @@ func (k unlockStatsVarKeyType) String() string { const UnlockStatsVarKey unlockStatsVarKeyType = 0 // Next implements the Executor Next interface. -func (e *UnlockStatsExec) Next(ctx context.Context, req *chunk.Chunk) error { +func (e *UnlockStatsExec) Next(_ context.Context, _ *chunk.Chunk) error { do := domain.GetDomain(e.ctx) is := do.InfoSchema() h := do.StatsHandle() @@ -152,6 +152,6 @@ func (e *UnlockStatsExec) Close() error { } // Open implements the Executor Open interface. -func (e *UnlockStatsExec) Open(ctx context.Context) error { +func (e *UnlockStatsExec) Open(_ context.Context) error { return nil } diff --git a/executor/memtable_reader.go b/executor/memtable_reader.go index 3c1530ed714cf..a299438da0777 100644 --- a/executor/memtable_reader.go +++ b/executor/memtable_reader.go @@ -49,6 +49,7 @@ import ( "golang.org/x/exp/slices" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" ) const clusterLogBatchSize = 256 @@ -431,7 +432,7 @@ func (e *clusterLogRetriever) startRetrieving( serversInfo []infoschema.ServerInfo, req *diagnosticspb.SearchLogRequest) ([]chan logStreamResult, error) { // gRPC options - opt := grpc.WithInsecure() + opt := grpc.WithTransportCredentials(insecure.NewCredentials()) security := config.GetGlobalConfig().Security if len(security.ClusterSSLCA) != 0 { clusterSecurity := security.ClusterSecurity() diff --git a/infoschema/tables.go b/infoschema/tables.go index 4d7ba5bb3a11d..58c5bc24c0951 100644 --- a/infoschema/tables.go +++ b/infoschema/tables.go @@ -2333,7 +2333,7 @@ func serverInfoItemToRows(items []*diagnosticspb.ServerInfoItem, tp, addr string } func getServerInfoByGRPC(ctx context.Context, address string, tp diagnosticspb.ServerInfoType) ([]*diagnosticspb.ServerInfoItem, error) { - opt := grpc.WithInsecure() + opt := grpc.WithTransportCredentials(insecure.NewCredentials()) security := config.GetGlobalConfig().Security if len(security.ClusterSSLCA) != 0 { clusterSecurity := security.ClusterSecurity() diff --git a/meta/autoid/BUILD.bazel b/meta/autoid/BUILD.bazel index b67f7f7c223c7..d6bcc1ef94689 100644 --- a/meta/autoid/BUILD.bazel +++ b/meta/autoid/BUILD.bazel @@ -32,6 +32,7 @@ go_library( "@io_etcd_go_etcd_client_v3//:client", "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//credentials", + "@org_golang_google_grpc//credentials/insecure", "@org_uber_go_zap//:zap", ], ) diff --git a/meta/autoid/autoid_service.go b/meta/autoid/autoid_service.go index 0b0f4946b3d0c..314ac3beef679 100644 --- a/meta/autoid/autoid_service.go +++ b/meta/autoid/autoid_service.go @@ -30,6 +30,7 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" ) var _ Allocator = &singlePointAlloc{} @@ -83,7 +84,7 @@ func (d *clientDiscover) GetClient(ctx context.Context) (autoid.AutoIDAllocClien } addr := string(resp.Kvs[0].Value) - opt := grpc.WithInsecure() + opt := grpc.WithTransportCredentials(insecure.NewCredentials()) security := config.GetGlobalConfig().Security if len(security.ClusterSSLCA) != 0 { clusterSecurity := security.ClusterSecurity() diff --git a/util/topsql/reporter/single_target.go b/util/topsql/reporter/single_target.go index bf66414b674d4..635a8dc9ab227 100644 --- a/util/topsql/reporter/single_target.go +++ b/util/topsql/reporter/single_target.go @@ -357,7 +357,7 @@ func (*SingleTargetDataSink) dial(ctx context.Context, targetRPCAddr string) (*g dialCtx, targetRPCAddr, grpc.WithBlock(), - grpc.WithInsecure(), + grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithInitialWindowSize(grpcInitialWindowSize), grpc.WithInitialConnWindowSize(grpcInitialConnWindowSize), grpc.WithDefaultCallOptions( diff --git a/util/topsql/topsql_test.go b/util/topsql/topsql_test.go index 04855ac163011..05d3c8d4647d1 100644 --- a/util/topsql/topsql_test.go +++ b/util/topsql/topsql_test.go @@ -241,7 +241,7 @@ func TestTopSQLPubSub(t *testing.T) { conn, err := grpc.Dial( server.Address(), grpc.WithBlock(), - grpc.WithInsecure(), + grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: 10 * time.Second, Timeout: 3 * time.Second, @@ -363,7 +363,7 @@ func TestPubSubWhenReporterIsStopped(t *testing.T) { conn, err := grpc.Dial( server.Address(), grpc.WithBlock(), - grpc.WithInsecure(), + grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: 10 * time.Second, Timeout: 3 * time.Second, From 3681d25f7df8ad3b42d3bfcb184b2a3f999f10c6 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 18:49:23 +0800 Subject: [PATCH 03/16] clean --- br/pkg/utils/misc.go | 1 + br/pkg/utils/store_manager.go | 1 + infoschema/tables.go | 1 + util/topsql/reporter/single_target.go | 1 + 4 files changed, 4 insertions(+) diff --git a/br/pkg/utils/misc.go b/br/pkg/utils/misc.go index d1d81d9df58af..ab62a7b7db534 100644 --- a/br/pkg/utils/misc.go +++ b/br/pkg/utils/misc.go @@ -23,6 +23,7 @@ import ( "github.com/pingcap/tidb/parser/types" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" ) // IsTypeCompatible checks whether type target is compatible with type src diff --git a/br/pkg/utils/store_manager.go b/br/pkg/utils/store_manager.go index 96c65a3d72be1..8a89e49022806 100644 --- a/br/pkg/utils/store_manager.go +++ b/br/pkg/utils/store_manager.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/backoff" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/keepalive" ) diff --git a/infoschema/tables.go b/infoschema/tables.go index 58c5bc24c0951..728b8cf1aa5a5 100644 --- a/infoschema/tables.go +++ b/infoschema/tables.go @@ -58,6 +58,7 @@ import ( "golang.org/x/exp/slices" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" ) const ( diff --git a/util/topsql/reporter/single_target.go b/util/topsql/reporter/single_target.go index 635a8dc9ab227..16c88956453cd 100644 --- a/util/topsql/reporter/single_target.go +++ b/util/topsql/reporter/single_target.go @@ -28,6 +28,7 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/backoff" + "google.golang.org/grpc/credentials/insecure" ) const ( From 3f69baf1c3856a800340b8e79edb8e6f91fb3d9d Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 18:49:35 +0800 Subject: [PATCH 04/16] clean --- br/pkg/utils/BUILD.bazel | 1 + infoschema/BUILD.bazel | 1 + util/topsql/reporter/BUILD.bazel | 1 + 3 files changed, 3 insertions(+) diff --git a/br/pkg/utils/BUILD.bazel b/br/pkg/utils/BUILD.bazel index 1cad8d5628dee..323b126eb5c6b 100644 --- a/br/pkg/utils/BUILD.bazel +++ b/br/pkg/utils/BUILD.bazel @@ -51,6 +51,7 @@ go_library( "@org_golang_google_grpc//backoff", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//credentials", + "@org_golang_google_grpc//credentials/insecure", "@org_golang_google_grpc//keepalive", "@org_golang_google_grpc//status", "@org_golang_x_net//http/httpproxy", diff --git a/infoschema/BUILD.bazel b/infoschema/BUILD.bazel index a92608a8df1b3..f827394be7904 100644 --- a/infoschema/BUILD.bazel +++ b/infoschema/BUILD.bazel @@ -56,6 +56,7 @@ go_library( "@com_github_tikv_client_go_v2//tikv", "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//credentials", + "@org_golang_google_grpc//credentials/insecure", "@org_golang_x_exp//slices", "@org_uber_go_zap//:zap", ], diff --git a/util/topsql/reporter/BUILD.bazel b/util/topsql/reporter/BUILD.bazel index 6c1def091ee39..98a83a0d00910 100644 --- a/util/topsql/reporter/BUILD.bazel +++ b/util/topsql/reporter/BUILD.bazel @@ -27,6 +27,7 @@ go_library( "@com_github_wangjohn_quickselect//:quickselect", "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//backoff", + "@org_golang_google_grpc//credentials/insecure", "@org_uber_go_atomic//:atomic", "@org_uber_go_zap//:zap", ], From 4ec4e9e1efa403710568fbd652246f5c32472440 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 18:56:48 +0800 Subject: [PATCH 05/16] clean --- br/pkg/lightning/backend/local/BUILD.bazel | 1 + br/pkg/lightning/backend/local/local.go | 1 + br/pkg/lightning/common/BUILD.bazel | 1 + br/pkg/lightning/common/security.go | 1 + br/pkg/restore/client.go | 1 + 5 files changed, 5 insertions(+) diff --git a/br/pkg/lightning/backend/local/BUILD.bazel b/br/pkg/lightning/backend/local/BUILD.bazel index 9524ab5febc2b..b09a1abad85ba 100644 --- a/br/pkg/lightning/backend/local/BUILD.bazel +++ b/br/pkg/lightning/backend/local/BUILD.bazel @@ -69,6 +69,7 @@ go_library( "@org_golang_google_grpc//backoff", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//credentials", + "@org_golang_google_grpc//credentials/insecure", "@org_golang_google_grpc//keepalive", "@org_golang_google_grpc//status", "@org_golang_x_exp//slices", diff --git a/br/pkg/lightning/backend/local/local.go b/br/pkg/lightning/backend/local/local.go index 08a0bdca503c2..11264031321a0 100644 --- a/br/pkg/lightning/backend/local/local.go +++ b/br/pkg/lightning/backend/local/local.go @@ -75,6 +75,7 @@ import ( "google.golang.org/grpc/backoff" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/keepalive" "google.golang.org/grpc/status" ) diff --git a/br/pkg/lightning/common/BUILD.bazel b/br/pkg/lightning/common/BUILD.bazel index a5245356b2715..bc04df82904a9 100644 --- a/br/pkg/lightning/common/BUILD.bazel +++ b/br/pkg/lightning/common/BUILD.bazel @@ -33,6 +33,7 @@ go_library( "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//credentials", + "@org_golang_google_grpc//credentials/insecure", "@org_golang_google_grpc//status", "@org_golang_x_sys//unix", "@org_uber_go_zap//:zap", diff --git a/br/pkg/lightning/common/security.go b/br/pkg/lightning/common/security.go index 753522be0cc50..8d0c98223d18a 100644 --- a/br/pkg/lightning/common/security.go +++ b/br/pkg/lightning/common/security.go @@ -28,6 +28,7 @@ import ( pd "github.com/tikv/pd/client" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" ) type TLS struct { diff --git a/br/pkg/restore/client.go b/br/pkg/restore/client.go index dce80d0d91c26..0d44d45da87eb 100644 --- a/br/pkg/restore/client.go +++ b/br/pkg/restore/client.go @@ -64,6 +64,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/backoff" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/keepalive" ) From d4ff496a7b7eb25f0e3230482908c755b1d6e403 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 19:13:41 +0800 Subject: [PATCH 06/16] clean --- util/topsql/BUILD.bazel | 1 + util/topsql/topsql_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/util/topsql/BUILD.bazel b/util/topsql/BUILD.bazel index f90cf35b09e8f..9cfac0291454c 100644 --- a/util/topsql/BUILD.bazel +++ b/util/topsql/BUILD.bazel @@ -42,6 +42,7 @@ go_test( "@com_github_pingcap_tipb//go-tipb", "@com_github_stretchr_testify//require", "@org_golang_google_grpc//:grpc", + "@org_golang_google_grpc//credentials/insecure", "@org_golang_google_grpc//keepalive", "@org_uber_go_goleak//:goleak", ], diff --git a/util/topsql/topsql_test.go b/util/topsql/topsql_test.go index 05d3c8d4647d1..1862b090a94de 100644 --- a/util/topsql/topsql_test.go +++ b/util/topsql/topsql_test.go @@ -32,6 +32,7 @@ import ( "github.com/pingcap/tipb/go-tipb" "github.com/stretchr/testify/require" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/keepalive" ) From 9891a50cb9f860a1fdcf3ca3b5891d870dc9aa39 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 20:51:26 +0800 Subject: [PATCH 07/16] clean --- build/nogo_config.json | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/build/nogo_config.json b/build/nogo_config.json index 15ca17ea9a485..e90a0dc2d0473 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -756,17 +756,12 @@ "util/gctuner": "util/gctuner", "util/cgroup": "util/cgroup code", "util/watcher": "util/watcher", - "br/pkg/lightning/restore/": "br/pkg/lightning/restore/", - "br/pkg/lightning/mydump/": "br/pkg/lightning/mydump/", + "br/pkg/": "br/pkg/lightning/", "executor/aggregate.go": "executor/aggregate.go", - "types/json_binary_functions.go": "types/json_binary_functions.go", - "types/json_binary_test.go": "types/json_binary_test.go", + "types/": "types", "ddl/": "enable to ddl", "expression/builtin_cast.go": "enable expression/builtin_cast.go", "planner/core/plan.go": "planner/core/plan.go", - "server/conn.go": "server/conn.go", - "server/conn_stmt.go": "server/conn_stmt.go", - "server/conn_test.go": "server/conn_test.go", "extension/": "extension code", "resourcemanager/": "resourcemanager code", "keyspace/": "keyspace code", From bb62bdb4216915c1a17a0b75bfa5d234ffe31d18 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 20:53:21 +0800 Subject: [PATCH 08/16] clean --- build/nogo_config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/nogo_config.json b/build/nogo_config.json index e90a0dc2d0473..5038271dbc04e 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -756,7 +756,7 @@ "util/gctuner": "util/gctuner", "util/cgroup": "util/cgroup code", "util/watcher": "util/watcher", - "br/pkg/": "br/pkg/lightning/", + "br/pkg/": "br/pkg/", "executor/aggregate.go": "executor/aggregate.go", "types/": "types", "ddl/": "enable to ddl", From 56b8a9667a448cfe6e73e728163ab0e2cecc3469 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 21:00:02 +0800 Subject: [PATCH 09/16] clean --- br/pkg/logutil/rate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/br/pkg/logutil/rate.go b/br/pkg/logutil/rate.go index 12ef85732efd7..e3e67ed241bff 100644 --- a/br/pkg/logutil/rate.go +++ b/br/pkg/logutil/rate.go @@ -51,5 +51,5 @@ func (r *RateTracer) RateAt(instant time.Time) float64 { // L make a logger with the current speed. func (r *RateTracer) L() *zap.Logger { - return log.With(zap.String("speed", fmt.Sprintf("%.2f ops/s", r.Rate()))) + return log.L().With(zap.String("speed", fmt.Sprintf("%.2f ops/s", r.Rate()))) } From 363ca092d61a7955db77d53baa64ff1b29229fbb Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 21:07:39 +0800 Subject: [PATCH 10/16] clean --- br/pkg/restore/split/client.go | 2 +- sessionctx/binloginfo/BUILD.bazel | 1 + sessionctx/binloginfo/binloginfo_test.go | 3 ++- store/mockstore/unistore/pd/BUILD.bazel | 1 + store/mockstore/unistore/pd/client.go | 3 ++- store/mockstore/unistore/tikv/BUILD.bazel | 1 + store/mockstore/unistore/tikv/deadlock.go | 3 ++- tidb-binlog/pump_client/BUILD.bazel | 2 ++ tidb-binlog/pump_client/bench_test.go | 3 ++- tidb-binlog/pump_client/client_test.go | 3 ++- tidb-binlog/pump_client/pump.go | 3 ++- 11 files changed, 18 insertions(+), 7 deletions(-) diff --git a/br/pkg/restore/split/client.go b/br/pkg/restore/split/client.go index b1151efd4d8b3..5f6788d6ee470 100644 --- a/br/pkg/restore/split/client.go +++ b/br/pkg/restore/split/client.go @@ -201,7 +201,7 @@ func (c *pdClient) SplitRegion(ctx context.Context, regionInfo *RegionInfo, key if err != nil { return nil, errors.Trace(err) } - conn, err := grpc.Dial(store.GetAddress(), grpc.WithInsecure()) + conn, err := grpc.Dial(store.GetAddress(), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return nil, errors.Trace(err) } diff --git a/sessionctx/binloginfo/BUILD.bazel b/sessionctx/binloginfo/BUILD.bazel index 7a843495273ea..3c345cd043469 100644 --- a/sessionctx/binloginfo/BUILD.bazel +++ b/sessionctx/binloginfo/BUILD.bazel @@ -54,6 +54,7 @@ go_test( "@com_github_pingcap_tipb//go-binlog", "@com_github_stretchr_testify//require", "@org_golang_google_grpc//:grpc", + "@org_golang_google_grpc//credentials/insecure", "@org_uber_go_goleak//:goleak", ], ) diff --git a/sessionctx/binloginfo/binloginfo_test.go b/sessionctx/binloginfo/binloginfo_test.go index 28235b5184b68..f6ca6bc059db8 100644 --- a/sessionctx/binloginfo/binloginfo_test.go +++ b/sessionctx/binloginfo/binloginfo_test.go @@ -45,6 +45,7 @@ import ( "github.com/pingcap/tipb/go-binlog" "github.com/stretchr/testify/require" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) type mockBinlogPump struct { @@ -100,7 +101,7 @@ func createBinlogSuite(t *testing.T) (s *binlogSuite) { opt := grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { return net.DialTimeout("unix", addr, timeout) }) - clientCon, err := grpc.Dial(unixFile, opt, grpc.WithInsecure()) + clientCon, err := grpc.Dial(unixFile, opt, grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) require.NotNil(t, clientCon) diff --git a/store/mockstore/unistore/pd/BUILD.bazel b/store/mockstore/unistore/pd/BUILD.bazel index e57867b014e47..5d5563cbdc153 100644 --- a/store/mockstore/unistore/pd/BUILD.bazel +++ b/store/mockstore/unistore/pd/BUILD.bazel @@ -12,6 +12,7 @@ go_library( "@com_github_pingcap_log//:log", "@com_github_tikv_pd_client//:client", "@org_golang_google_grpc//:grpc", + "@org_golang_google_grpc//credentials/insecure", "@org_uber_go_zap//:zap", ], ) diff --git a/store/mockstore/unistore/pd/client.go b/store/mockstore/unistore/pd/client.go index 55547e9461899..96d53eb8d54bf 100644 --- a/store/mockstore/unistore/pd/client.go +++ b/store/mockstore/unistore/pd/client.go @@ -29,6 +29,7 @@ import ( pd "github.com/tikv/pd/client" "go.uber.org/zap" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) // Client is a PD (Placement Driver) client. @@ -231,7 +232,7 @@ func (c *client) getOrCreateConn(addr string) (*grpc.ClientConn, error) { if err != nil { return nil, err } - cc, err := grpc.Dial(u.Host, grpc.WithInsecure()) + cc, err := grpc.Dial(u.Host, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return nil, err } diff --git a/store/mockstore/unistore/tikv/BUILD.bazel b/store/mockstore/unistore/tikv/BUILD.bazel index 91db06dd09dfa..bc7ecacf382fc 100644 --- a/store/mockstore/unistore/tikv/BUILD.bazel +++ b/store/mockstore/unistore/tikv/BUILD.bazel @@ -54,6 +54,7 @@ go_library( "@com_github_tikv_client_go_v2//oracle", "@com_github_tikv_pd_client//:client", "@org_golang_google_grpc//:grpc", + "@org_golang_google_grpc//credentials/insecure", "@org_golang_x_exp//slices", "@org_uber_go_zap//:zap", ], diff --git a/store/mockstore/unistore/tikv/deadlock.go b/store/mockstore/unistore/tikv/deadlock.go index 7eeb1fb2c5b64..7e8b0179e082d 100644 --- a/store/mockstore/unistore/tikv/deadlock.go +++ b/store/mockstore/unistore/tikv/deadlock.go @@ -27,6 +27,7 @@ import ( "github.com/pingcap/tidb/store/mockstore/unistore/util/lockwaiter" "go.uber.org/zap" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) // Follower will send detection rpc to Leader @@ -100,7 +101,7 @@ func (dt *DetectorClient) rebuildStreamClient() error { if err != nil { return err } - cc, err := grpc.Dial(leaderAddr, grpc.WithInsecure()) + cc, err := grpc.Dial(leaderAddr, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return err } diff --git a/tidb-binlog/pump_client/BUILD.bazel b/tidb-binlog/pump_client/BUILD.bazel index ad98822adaf5b..863fe7b61f8f9 100644 --- a/tidb-binlog/pump_client/BUILD.bazel +++ b/tidb-binlog/pump_client/BUILD.bazel @@ -21,6 +21,7 @@ go_library( "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//credentials", + "@org_golang_google_grpc//credentials/insecure", "@org_golang_google_grpc//status", "@org_uber_go_zap//:zap", ], @@ -41,5 +42,6 @@ go_test( "@com_github_pingcap_tipb//go-binlog", "@com_github_stretchr_testify//require", "@org_golang_google_grpc//:grpc", + "@org_golang_google_grpc//credentials/insecure", ], ) diff --git a/tidb-binlog/pump_client/bench_test.go b/tidb-binlog/pump_client/bench_test.go index fe3eb2f6ffb30..ae93203319e21 100644 --- a/tidb-binlog/pump_client/bench_test.go +++ b/tidb-binlog/pump_client/bench_test.go @@ -23,6 +23,7 @@ import ( pb "github.com/pingcap/tipb/go-binlog" "github.com/stretchr/testify/require" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) func Benchmark100Thread(b *testing.B) { @@ -86,7 +87,7 @@ func createMockPumpsClientAndServer(b *testing.B) (*PumpsClient, *mockPumpServer return net.DialTimeout("tcp", addr, timeout) }) - clientCon, err := grpc.Dial(addr, opt, grpc.WithInsecure()) + clientCon, err := grpc.Dial(addr, opt, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { b.Fatal(err) } diff --git a/tidb-binlog/pump_client/client_test.go b/tidb-binlog/pump_client/client_test.go index ac287773072ed..974ed76d29aa8 100644 --- a/tidb-binlog/pump_client/client_test.go +++ b/tidb-binlog/pump_client/client_test.go @@ -27,6 +27,7 @@ import ( "github.com/pingcap/tipb/go-binlog" "github.com/stretchr/testify/require" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) var ( @@ -176,7 +177,7 @@ func TestWriteBinlog(t *testing.T) { opt := grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { return net.DialTimeout(cfg.serverMode, addr, timeout) }) - clientCon, err := grpc.Dial(cfg.addr, opt, grpc.WithInsecure()) + clientCon, err := grpc.Dial(cfg.addr, opt, grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) require.NotNil(t, clientCon) pumpClient := mockPumpsClient(binlog.NewPumpClient(clientCon), true) diff --git a/tidb-binlog/pump_client/pump.go b/tidb-binlog/pump_client/pump.go index 82fa48da92da2..4459bb1bfc5ef 100644 --- a/tidb-binlog/pump_client/pump.go +++ b/tidb-binlog/pump_client/pump.go @@ -29,6 +29,7 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" ) var ( @@ -103,7 +104,7 @@ func (p *PumpStatus) createGrpcClient() error { if p.security != nil { clientConn, err = grpc.Dial(p.Addr, dialerOpt, grpc.WithTransportCredentials(credentials.NewTLS(p.security))) } else { - clientConn, err = grpc.Dial(p.Addr, dialerOpt, grpc.WithInsecure()) + clientConn, err = grpc.Dial(p.Addr, dialerOpt, grpc.WithTransportCredentials(insecure.NewCredentials())) } if err != nil { atomic.AddInt64(&p.ErrNum, 1) From d4d4fea06a3826fb73c7e5aced63e67bcaa4efa0 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 21:16:28 +0800 Subject: [PATCH 11/16] clean --- build/nogo_config.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/nogo_config.json b/build/nogo_config.json index 5038271dbc04e..83cba9ddd100b 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -750,13 +750,14 @@ "/build/": "no need to linter code", "/external/": "no need to vet third party code", ".*_generated\\.go$": "ignore generated code", - ".*_test\\.go$": "ignore test code" + ".*_test\\.go$": "ignore test code", + "br/pkg/restore/split/client.go": "br/pkg/restore/split/client.go" }, "only_files": { "util/gctuner": "util/gctuner", "util/cgroup": "util/cgroup code", "util/watcher": "util/watcher", - "br/pkg/": "br/pkg/", + "br/pkg/": "br/pkg", "executor/aggregate.go": "executor/aggregate.go", "types/": "types", "ddl/": "enable to ddl", From 6008b7285927674bda042c8ff8034f3400f939bd Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 21:38:21 +0800 Subject: [PATCH 12/16] clean --- build/nogo_config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/nogo_config.json b/build/nogo_config.json index 83cba9ddd100b..e4f237220de48 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -751,7 +751,8 @@ "/external/": "no need to vet third party code", ".*_generated\\.go$": "ignore generated code", ".*_test\\.go$": "ignore test code", - "br/pkg/restore/split/client.go": "br/pkg/restore/split/client.go" + "br/pkg/restore/split/client.go": "github.com/golang/protobuf deprecated", + "br/pkg/streamhelper/advancer_cliext.go", "github.com/golang/protobuf deprecated" }, "only_files": { "util/gctuner": "util/gctuner", From fe729c5a7fc0eb1ea1ea978a0947d0a46e3b27f2 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 21:41:43 +0800 Subject: [PATCH 13/16] clean --- build/nogo_config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/nogo_config.json b/build/nogo_config.json index e4f237220de48..3f811369530d7 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -752,7 +752,7 @@ ".*_generated\\.go$": "ignore generated code", ".*_test\\.go$": "ignore test code", "br/pkg/restore/split/client.go": "github.com/golang/protobuf deprecated", - "br/pkg/streamhelper/advancer_cliext.go", "github.com/golang/protobuf deprecated" + "br/pkg/streamhelper/advancer_cliext.go": "github.com/golang/protobuf deprecated" }, "only_files": { "util/gctuner": "util/gctuner", From da96d4b836a3b9d910a00145738cac580cdcf2b7 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 21:50:21 +0800 Subject: [PATCH 14/16] clean --- build/nogo_config.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/nogo_config.json b/build/nogo_config.json index 3f811369530d7..09c309417d454 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -752,7 +752,9 @@ ".*_generated\\.go$": "ignore generated code", ".*_test\\.go$": "ignore test code", "br/pkg/restore/split/client.go": "github.com/golang/protobuf deprecated", - "br/pkg/streamhelper/advancer_cliext.go": "github.com/golang/protobuf deprecated" + "br/pkg/streamhelper/advancer_cliext.go": "github.com/golang/protobuf deprecated", + "br/pkg/lightning/checkpoints/checkpoints.go": "cfg.TikvImporter.Addr is deprecated", + "br/pkg/lightning/checkpoints/glue_checkpoint.go": "cfg.TikvImporter.Addr is deprecated" }, "only_files": { "util/gctuner": "util/gctuner", From f7aead9b1f183d9dccc15a9ad4cbbad684483911 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 22 Jan 2023 22:03:10 +0800 Subject: [PATCH 15/16] clean --- br/pkg/backup/client.go | 2 +- br/pkg/backup/schema.go | 2 +- br/pkg/restore/client.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/br/pkg/backup/client.go b/br/pkg/backup/client.go index 927f3937963a0..daac9609ae5f4 100644 --- a/br/pkg/backup/client.go +++ b/br/pkg/backup/client.go @@ -556,7 +556,7 @@ func BuildBackupRangeAndSchema( continue } - logger := log.With( + logger := log.L().With( zap.String("db", dbInfo.Name.O), zap.String("table", tableInfo.Name.O), ) diff --git a/br/pkg/backup/schema.go b/br/pkg/backup/schema.go index bb0cf7f884189..f42976272ea54 100644 --- a/br/pkg/backup/schema.go +++ b/br/pkg/backup/schema.go @@ -117,7 +117,7 @@ func (ss *Schemas) BackupSchemas( } workerPool.ApplyOnErrorGroup(errg, func() error { if schema.tableInfo != nil { - logger := log.With( + logger := log.L().With( zap.String("db", schema.dbInfo.Name.O), zap.String("table", schema.tableInfo.Name.O), ) diff --git a/br/pkg/restore/client.go b/br/pkg/restore/client.go index 0d44d45da87eb..18a3dc61879e4 100644 --- a/br/pkg/restore/client.go +++ b/br/pkg/restore/client.go @@ -1411,7 +1411,7 @@ func (rc *Client) execChecksum( concurrency uint, loadStatCh chan<- *CreatedTable, ) error { - logger := log.With( + logger := log.L().With( zap.String("db", tbl.OldTable.DB.Name.O), zap.String("table", tbl.OldTable.Info.Name.O), ) From 1c34f1e27d7adc1cea5bb45ab0b3d82a0522cae5 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Fri, 27 Jan 2023 23:45:53 +0800 Subject: [PATCH 16/16] clean Signed-off-by: Weizhen Wang --- build/nogo_config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/nogo_config.json b/build/nogo_config.json index 09c309417d454..0aa1bd67a2217 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -769,7 +769,8 @@ "extension/": "extension code", "resourcemanager/": "resourcemanager code", "keyspace/": "keyspace code", - "server/": "server code" + "server/": "server code", + "meta": "meta code" } }, "SA2000": {