From 06c954c6f74c72b6e181346ebdeb68d9765c6681 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Thu, 26 Oct 2023 11:44:03 +0800 Subject: [PATCH] br: avoid retry if it's ec2metadata (#47651) (#47790) close pingcap/tidb#47650 --- br/pkg/storage/s3.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/br/pkg/storage/s3.go b/br/pkg/storage/s3.go index d6d29706825bc..67c95bfccbd01 100644 --- a/br/pkg/storage/s3.go +++ b/br/pkg/storage/s3.go @@ -969,14 +969,14 @@ func (rl retryerWithLog) ShouldRetry(r *request.Request) bool { r.Error = errors.New("read tcp *.*.*.*:*->*.*.*.*:*: read: connection reset by peer") } }) - if isConnectionResetError(r.Error) { - return true - } - if isDeadlineExceedError(r.Error) && r.HTTPRequest.URL.Host == ec2MetaAddress { + if r.HTTPRequest.URL.Host == ec2MetaAddress && (isDeadlineExceedError(r.Error) || isConnectionResetError(r.Error)) { // fast fail for unreachable linklocal address in EC2 containers. log.Warn("failed to get EC2 metadata. skipping.", logutil.ShortError(r.Error)) return false } + if isConnectionResetError(r.Error) { + return true + } return rl.DefaultRetryer.ShouldRetry(r) }