Skip to content

Commit

Permalink
cherry pick pingcap#24577 to release-5.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
hanfei1991 authored and ti-srebot committed May 12, 2021
1 parent 41c0f17 commit f69f0ee
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions store/copr/batch_coprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ func buildBatchCopTasks(bo *tikv.Backoffer, cache *tikv.RegionCache, ranges *tik
if err != nil {
return nil, errors.Trace(err)
}
// If the region is not found in cache, it must be out
// of date and already be cleaned up. We should retry and generate new tasks.
// When rpcCtx is nil, it's not only attributed to the miss region, but also
// some TiFlash stores crash and can't be recovered.
// That is not an error that can be easily recovered, so we regard this error
// same as rpc error.
if rpcCtx == nil {
needRetry = true
logutil.BgLogger().Info("retry for TiFlash peer with region missing", zap.Uint64("region id", task.region.GetID()))
Expand All @@ -146,8 +148,10 @@ func buildBatchCopTasks(bo *tikv.Backoffer, cache *tikv.RegionCache, ranges *tik
}
}
if needRetry {
// Backoff once for each retry.
err = bo.Backoff(tikv.BoRegionMiss, errors.New("Cannot find region with TiFlash peer"))
// As mentioned above, nil rpcCtx is always attributed to failed stores.
// It's equal to long poll the store but get no response. Here we'd better use
// TiFlash error to trigger the TiKV fallback mechanism.
err = bo.Backoff(tikv.BoTiFlashRPC, errors.New("Cannot find region with TiFlash peer"))
if err != nil {
return nil, errors.Trace(err)
}
Expand Down

0 comments on commit f69f0ee

Please sign in to comment.