From b664848937dbba58aa5ee26a02948ab7618c55a0 Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Mon, 18 Nov 2019 21:00:25 +0800 Subject: [PATCH] fix the max recv message size for the client Signed-off-by: Ryan Leung --- pkg/grpcutil/grpcutil.go | 4 ++-- server/region_syncer/client.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/grpcutil/grpcutil.go b/pkg/grpcutil/grpcutil.go index af120b0f22f..b76692db0a9 100644 --- a/pkg/grpcutil/grpcutil.go +++ b/pkg/grpcutil/grpcutil.go @@ -25,7 +25,7 @@ import ( ) // GetClientConn returns a gRPC client connection. -func GetClientConn(addr string, caPath string, certPath string, keyPath string) (*grpc.ClientConn, error) { +func GetClientConn(addr string, caPath string, certPath string, keyPath string, do ...grpc.DialOption) (*grpc.ClientConn, error) { opt := grpc.WithInsecure() if len(caPath) != 0 { certificates := []tls.Certificate{} @@ -61,7 +61,7 @@ func GetClientConn(addr string, caPath string, certPath string, keyPath string) if err != nil { return nil, errors.WithStack(err) } - cc, err := grpc.Dial(u.Host, opt) + cc, err := grpc.Dial(u.Host, append(do, opt)...) if err != nil { return nil, errors.WithStack(err) } diff --git a/server/region_syncer/client.go b/server/region_syncer/client.go index e5581bf8fbc..270122afb42 100644 --- a/server/region_syncer/client.go +++ b/server/region_syncer/client.go @@ -23,6 +23,7 @@ import ( "github.com/pingcap/pd/server/core" "github.com/pkg/errors" "go.uber.org/zap" + "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -51,7 +52,7 @@ func (s *RegionSyncer) reset() { func (s *RegionSyncer) establish(addr string) (ClientStream, error) { s.reset() - cc, err := grpcutil.GetClientConn(addr, s.securityConfig["caPath"], s.securityConfig["certPath"], s.securityConfig["keyPath"]) + cc, err := grpcutil.GetClientConn(addr, s.securityConfig["caPath"], s.securityConfig["certPath"], s.securityConfig["keyPath"], grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(msgSize))) if err != nil { return nil, errors.WithStack(err) }