restore: fix failed to retry grpc errors (#27423)
This commit is contained in:
@ -56,7 +56,8 @@ func (bo *importerBackoffer) NextBackoff(err error) time.Duration {
|
||||
bo.delayTime = 2 * bo.delayTime
|
||||
bo.attempt--
|
||||
} else {
|
||||
switch errors.Cause(err) { // nolint:errorlint
|
||||
e := errors.Cause(err)
|
||||
switch e { // nolint:errorlint
|
||||
case berrors.ErrKVEpochNotMatch, berrors.ErrKVDownloadFailed, berrors.ErrKVIngestFailed:
|
||||
bo.delayTime = 2 * bo.delayTime
|
||||
bo.attempt--
|
||||
@ -65,7 +66,7 @@ func (bo *importerBackoffer) NextBackoff(err error) time.Duration {
|
||||
bo.delayTime = 0
|
||||
bo.attempt = 0
|
||||
default:
|
||||
switch status.Code(err) {
|
||||
switch status.Code(e) {
|
||||
case codes.Unavailable, codes.Aborted:
|
||||
bo.delayTime = 2 * bo.delayTime
|
||||
bo.attempt--
|
||||
|
||||
@ -317,6 +317,10 @@ func (importer *FileImporter) Import(
|
||||
log.Debug("failpoint restore-storage-error injected.", zap.String("msg", msg))
|
||||
e = errors.Annotate(e, msg)
|
||||
})
|
||||
failpoint.Inject("restore-gRPC-error", func(_ failpoint.Value) {
|
||||
log.Warn("the connection to TiKV has been cut by a neko, meow :3")
|
||||
e = status.Error(codes.Unavailable, "the connection to TiKV has been cut by a neko, meow :3")
|
||||
})
|
||||
if e != nil {
|
||||
remainFiles = remainFiles[i:]
|
||||
return errors.Trace(e)
|
||||
|
||||
@ -70,7 +70,7 @@ for ct in limit lz4 zstd; do
|
||||
|
||||
# restore full
|
||||
echo "restore with $ct backup start..."
|
||||
export GO_FAILPOINTS="github.com/pingcap/tidb/br/pkg/restore/restore-storage-error=1*return(\"connection refused\")"
|
||||
export GO_FAILPOINTS="github.com/pingcap/tidb/br/pkg/restore/restore-storage-error=1*return(\"connection refused\");github.com/pingcap/tidb/br/pkg/restore/restore-gRPC-error=1*return(true)"
|
||||
run_br restore full -s "local://$TEST_DIR/$DB-$ct" --pd $PD_ADDR --ratelimit 1024
|
||||
export GO_FAILPOINTS=""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user