Skip to content

Commit

Permalink
grpc: allow client send consecutive pings in every 5 seconds (tikv#294)
Browse files Browse the repository at this point in the history
Signed-off-by: yongman <yming0221@gmail.com>
  • Loading branch information
yongman authored Aug 1, 2024
1 parent 45a2598 commit ac9ea37
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 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 ac9ea37

Please sign in to comment.