diff --git a/internal/locate/region_request.go b/internal/locate/region_request.go index 9c9e613e0..a83b93dcc 100644 --- a/internal/locate/region_request.go +++ b/internal/locate/region_request.go @@ -1449,13 +1449,13 @@ func (s *RegionRequestSender) SendReqCtx( } } - if e := tikvrpc.SetContext(req, rpcCtx.Meta, rpcCtx.Peer); e != nil { - return nil, nil, retryTimes, err - } rpcCtx.contextPatcher.applyTo(&req.Context) if req.InputRequestSource != "" && s.replicaSelector != nil { s.replicaSelector.patchRequestSource(req, rpcCtx) } + if e := tikvrpc.SetContext(req, rpcCtx.Meta, rpcCtx.Peer); e != nil { + return nil, nil, retryTimes, err + } var retry bool resp, retry, err = s.sendReqToRegion(bo, rpcCtx, req, timeout)