diff --git a/store/tikv/region_request.go b/store/tikv/region_request.go index f49149ce3e4e1..4765e649a23a1 100644 --- a/store/tikv/region_request.go +++ b/store/tikv/region_request.go @@ -286,7 +286,9 @@ func (s *RegionRequestSender) SendReqCtx( if err != nil { return nil, nil, err } - rpcCtx.lastPeerID = lastPeerID + if rpcCtx != nil { + rpcCtx.lastPeerID = lastPeerID + } failpoint.Inject("invalidCacheAndRetry", func() { // cooperate with github.com/pingcap/tidb/store/gcworker/setGcResolveMaxBackoff