Skip to content

Commit

Permalink
rpc: restore 20s connect timeout for grpc dialer
Browse files Browse the repository at this point in the history
Changes in cockroachdb#49114 lead to default connect timeout value dropping
to 0 instead of default 20s.

This is not always enough for multiregion clients with hub spoke
network topologies as connections don't have enough time to initially
go through.
This change restores initial value that matches grpc defaults.

Release note (bug fix): Connect timeout for grpc connections is
set to 20s to match pre 20.2 default value.
  • Loading branch information
aliher1911 committed Oct 13, 2021
1 parent 55f6c67 commit af2fe7c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/rpc/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ const (
initialConnWindowSize = initialWindowSize * 16 // for a connection
)

// GRPC Dialer connection timeout. 20s matches default value that is
// suppressed when backoff config is provided.
const minConnectionTimeout = 20 * time.Second

// sourceAddr is the environment-provided local address for outgoing
// connections.
var sourceAddr = func() net.Addr {
Expand Down Expand Up @@ -967,7 +971,9 @@ func (ctx *Context) grpcDialRaw(
// ~second range.
backoffConfig := backoff.DefaultConfig
backoffConfig.MaxDelay = maxBackoff
dialOpts = append(dialOpts, grpc.WithConnectParams(grpc.ConnectParams{Backoff: backoffConfig}))
dialOpts = append(dialOpts, grpc.WithConnectParams(grpc.ConnectParams{
Backoff: backoffConfig,
MinConnectTimeout: minConnectionTimeout}))
dialOpts = append(dialOpts, grpc.WithKeepaliveParams(clientKeepalive))
dialOpts = append(dialOpts,
grpc.WithInitialWindowSize(initialWindowSize),
Expand Down

0 comments on commit af2fe7c

Please sign in to comment.