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
#20031)

Signed-off-by: ti-srebot <[email protected]>
  • Loading branch information
ti-srebot authored Sep 18, 2020
1 parent 0f49dd0 commit 6d71e24
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 @@ -400,6 +400,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 6d71e24

Please sign in to comment.