From 156ed6a2c9a9866e20c11901ddee97470e02cf75 Mon Sep 17 00:00:00 2001 From: disksing Date: Wed, 30 Jun 2021 11:55:45 +0800 Subject: [PATCH] update tidb and clean up unused code (#190) Signed-off-by: disksing --- client/client.go | 5 ----- integration_tests/go.mod | 2 +- integration_tests/go.sum | 14 ++++++-------- mockstore/mocktikv/rpc.go | 36 ------------------------------------ tikv/client.go | 5 ----- 5 files changed, 7 insertions(+), 55 deletions(-) diff --git a/client/client.go b/client/client.go index fb86e416..50e34292 100644 --- a/client/client.go +++ b/client/client.go @@ -271,11 +271,6 @@ func NewRPCClient(security config.Security, opts ...func(c *RPCClient)) *RPCClie return cli } -// NewTestRPCClient is for some external tests. -func NewTestRPCClient(security config.Security) Client { - return NewRPCClient(security) -} - func (c *RPCClient) getConnArray(addr string, enableBatch bool, opt ...func(cfg *config.TiKVClient)) (*connArray, error) { c.RLock() if c.isClosed { diff --git a/integration_tests/go.mod b/integration_tests/go.mod index 4096013b..77ef8108 100644 --- a/integration_tests/go.mod +++ b/integration_tests/go.mod @@ -8,7 +8,7 @@ require ( github.com/pingcap/failpoint v0.0.0-20210316064728-7acb0f0a3dfd github.com/pingcap/kvproto v0.0.0-20210611081648-a215b4e61d2f github.com/pingcap/parser v0.0.0-20210618053735-57843e8185c4 - github.com/pingcap/tidb v1.1.0-beta.0.20210623034522-9a2e5f99a6f9 + github.com/pingcap/tidb v1.1.0-beta.0.20210630013525-0e1420db12d4 github.com/stretchr/testify v1.7.0 github.com/tikv/client-go/v2 v2.0.0 github.com/tikv/pd v1.1.0-beta.0.20210323121136-78679e5e209d diff --git a/integration_tests/go.sum b/integration_tests/go.sum index 9b92b718..1d7ba7a2 100644 --- a/integration_tests/go.sum +++ b/integration_tests/go.sum @@ -433,13 +433,13 @@ github.com/pingcap/parser v0.0.0-20210618053735-57843e8185c4/go.mod h1:xZC8I7bug github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI= github.com/pingcap/sysutil v0.0.0-20210315073920-cc0985d983a3 h1:A9KL9R+lWSVPH8IqUuH1QSTRJ5FGoY1bT2IcfPKsWD8= github.com/pingcap/sysutil v0.0.0-20210315073920-cc0985d983a3/go.mod h1:tckvA041UWP+NqYzrJ3fMgC/Hw9wnmQ/tUkp/JaHly8= -github.com/pingcap/tidb v1.1.0-beta.0.20210623034522-9a2e5f99a6f9 h1:SWsw9W1JRCWR8YzlQ+gKtV5JwtpjGsDtACe6Iy1d2wY= -github.com/pingcap/tidb v1.1.0-beta.0.20210623034522-9a2e5f99a6f9/go.mod h1:X3nGJTaZf9Ltr3nCiLKmNLJeMvvrqMrVe5WGx7NjayA= +github.com/pingcap/tidb v1.1.0-beta.0.20210630013525-0e1420db12d4 h1:x087K40I4zm9hUo7BmJk1q52O7DPPmv8tfnDXIYHkBU= +github.com/pingcap/tidb v1.1.0-beta.0.20210630013525-0e1420db12d4/go.mod h1:bszEbe/WvvmVFNh4BVjyb/8YDjlA7IxweZLQy+EVBmk= github.com/pingcap/tidb-dashboard v0.0.0-20210312062513-eef5d6404638/go.mod h1:OzFN8H0EDMMqeulPhPMw2i2JaiZWOKFQ7zdRPhENNgo= github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible h1:ceznmu/lLseGHP/jKyOa/3u/5H3wtLLLqkH2V3ssSjg= github.com/pingcap/tidb-tools v4.0.9-0.20201127090955-2707c97b3853+incompatible/go.mod h1:XGdcy9+yqlDSEMTpOXnwf3hiTeqrV6MN/u1se9N8yIM= -github.com/pingcap/tipb v0.0.0-20210603161937-cfb5a9225f95 h1:Cj7FhGvYn8hrXDNcaHi0aTl0KdV67KTL+P5gBp3vqT4= -github.com/pingcap/tipb v0.0.0-20210603161937-cfb5a9225f95/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs= +github.com/pingcap/tipb v0.0.0-20210628060001-1793e022b962 h1:9Y9Eci9LwAEhyXAlAU0bSix7Nemm3G267oyN3GVK+j0= +github.com/pingcap/tipb v0.0.0-20210628060001-1793e022b962/go.mod h1:A7mrd7WHBl1o63LE2bIBGEJMTNWXqhgmYiOvMLxozfs= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -587,8 +587,9 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= +go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd v0.5.0-alpha.5.0.20200824191128-ae9734ed278b h1:3kC4J3eQF6p1UEfQTkC67eEeb3rTk+shQqdX6tFyq9Q= @@ -706,7 +707,6 @@ golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -764,8 +764,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/mockstore/mocktikv/rpc.go b/mockstore/mocktikv/rpc.go index 280b3070..2a533bd5 100644 --- a/mockstore/mocktikv/rpc.go +++ b/mockstore/mocktikv/rpc.go @@ -37,7 +37,6 @@ import ( "context" "math" "strconv" - "sync" "time" "github.com/opentracing/opentracing-go" @@ -592,11 +591,6 @@ type RPCClient struct { Cluster *Cluster MvccStore MVCCStore coprHandler CoprRPCHandler - // rpcCli uses to redirects RPC request to TiDB rpc server, It is only use for test. - // Mock TiDB rpc service will have circle import problem, so just use a real RPC client to send this RPC server. - // sync.Once uses to avoid concurrency initialize rpcCli. - sync.Once - rpcCli Client } // NewRPCClient creates an RPCClient. @@ -644,25 +638,6 @@ func (c *RPCClient) checkArgs(ctx context.Context, addr string) (*Session, error return session, nil } -// GRPCClientFactory is the GRPC client factory. -// Use global variable to avoid circle import. -// TODO: remove this global variable. -var GRPCClientFactory func() Client - -// redirectRequestToRPCServer redirects RPC request to TiDB rpc server, It is only use for test. -// Mock TiDB rpc service will have circle import problem, so just use a real RPC client to send this RPC server. -func (c *RPCClient) redirectRequestToRPCServer(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (*tikvrpc.Response, error) { - c.Once.Do(func() { - if GRPCClientFactory != nil { - c.rpcCli = GRPCClientFactory() - } - }) - if c.rpcCli == nil { - return nil, errors.Errorf("GRPCClientFactory is nil") - } - return c.rpcCli.SendRequest(ctx, addr, req, timeout) -} - // SendRequest sends a request to mock cluster. func (c *RPCClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (*tikvrpc.Response, error) { if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil { @@ -677,10 +652,6 @@ func (c *RPCClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.R reqCtx := &req.Context resp := &tikvrpc.Response{} - // When the store type is TiDB, the request should handle over to TiDB rpc server to handle. - if req.StoreTp == tikvrpc.TiDB { - return c.redirectRequestToRPCServer(ctx, addr, req, timeout) - } session, err := c.checkArgs(ctx, addr) if err != nil { @@ -981,12 +952,5 @@ func (c *RPCClient) Close() error { return err } } - - if c.rpcCli != nil { - err = c.rpcCli.Close() - if err != nil { - return err - } - } return nil } diff --git a/tikv/client.go b/tikv/client.go index a11242c8..8fb903d1 100644 --- a/tikv/client.go +++ b/tikv/client.go @@ -47,11 +47,6 @@ const ( ReadTimeoutShort = client.ReadTimeoutShort ) -// NewTestRPCClient is for some external tests. -func NewTestRPCClient(security config.Security) Client { - return client.NewTestRPCClient(security) -} - // NewRPCClient creates a client that manages connections and rpc calls with tikv-servers. func NewRPCClient(security config.Security, opts ...func(c *client.RPCClient)) *client.RPCClient { return client.NewRPCClient(security, opts...)