Skip to content

Commit

Permalink
grpc: allow client send consecutive pings in every 5 seconds (#8120)
Browse files Browse the repository at this point in the history
close #8119

grpc: allow client send consecutive pings in every 5 seconds

Signed-off-by: yongman <[email protected]>

Co-authored-by: Hu# <[email protected]>
  • Loading branch information
yongman and HuSharp authored Jul 16, 2024
1 parent ca179e6 commit cbba49a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/mcs/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"go.etcd.io/etcd/pkg/types"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/keepalive"
)

const (
Expand Down Expand Up @@ -229,7 +230,14 @@ func StartGRPCAndHTTPServers(s server, serverReadyChan chan<- struct{}, l net.Li
httpListener = mux.Match(cmux.HTTP1())
}

grpcServer := grpc.NewServer()
grpcServer := grpc.NewServer(
// Allow clients send consecutive pings in every 5 seconds.
// The default value of MinTime is 5 minutes,
// which is too long compared with 10 seconds of TiKV's pd client keepalive time.
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
MinTime: 5 * time.Second,
}),
)
s.SetGRPCServer(grpcServer)
s.RegisterGRPCService(grpcServer)
diagnosticspb.RegisterDiagnosticsServer(grpcServer, s)
Expand Down

0 comments on commit cbba49a

Please sign in to comment.