Skip to content

Commit

Permalink
tikv: fix unexpected retry region request when context cancel (#20030)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzmhhh123 authored Sep 16, 2020
1 parent 4b7c5db commit 1dcd156
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions store/tikv/region_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,13 @@ func (s *RegionRequestSender) sendReqToRegion(bo *Backoffer, rpcCtx *RPCContext,
}
resp, err = s.client.SendRequest(ctx, rpcCtx.Addr, req, timeout)
if err != nil {
// Because in rpc logic, context.Cancel() will be transferred to rpcContext.Cancel error. For rpcContext cancel,
// we need to retry the request. But for context cancel active, for example, limitExec gets the required rows,
// we shouldn't retry the request, it will go to backoff and hang in retry logic.
if ctx.Err() != nil && errors.Cause(ctx.Err()) == context.Canceled {
return nil, false, errors.Trace(ctx.Err())
}

s.rpcError = err
if e := s.onSendFail(bo, rpcCtx, err); e != nil {
return nil, false, errors.Trace(e)
Expand Down

0 comments on commit 1dcd156

Please sign in to comment.