Skip to content

Commit

Permalink
Merge pull request #34192 from ajwerner/backport2.1-34026
Browse files Browse the repository at this point in the history
release-2.1: rpc/nodedialer: check context for cancellation before dialing
  • Loading branch information
ajwerner authored Jan 23, 2019
2 parents 38b435b + 02ba0f2 commit 772c800
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/rpc/nodedialer/nodedialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ func (n *Dialer) Dial(ctx context.Context, nodeID roachpb.NodeID) (_ *grpc.Clien
if n == nil || n.resolver == nil {
return nil, errors.New("no node dialer configured")
}
// Don't trip the breaker if we're already canceled.
if ctxErr := ctx.Err(); ctxErr != nil {
return nil, ctxErr
}
breaker := n.getBreaker(nodeID)

if !breaker.Ready() {
Expand Down Expand Up @@ -118,6 +122,10 @@ func (n *Dialer) DialInternalClient(
if n == nil || n.resolver == nil {
return nil, nil, errors.New("no node dialer configured")
}
// Don't trip the breaker if we're already canceled.
if ctxErr := ctx.Err(); ctxErr != nil {
return nil, nil, ctxErr
}
addr, err := n.resolver(nodeID)
if err != nil {
return nil, nil, err
Expand Down

0 comments on commit 772c800

Please sign in to comment.