From f4a139ffe346c67bfc3138868cd22cc4aacd32fb Mon Sep 17 00:00:00 2001
From: Jianjun Liao <36503113+Leavrth@users.noreply.github.com>
Date: Thu, 19 Oct 2023 17:00:29 +0800
Subject: [PATCH] br: avoid retry if it's ec2metadata (#47651)
close pingcap/tidb#47650
---
br/pkg/storage/s3.go | 10 +++++-----
br/tests/br_full/run.sh | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/br/pkg/storage/s3.go b/br/pkg/storage/s3.go
index 2ba28a39d0a09..14ff8fc717fb5 100644
--- a/br/pkg/storage/s3.go
+++ b/br/pkg/storage/s3.go
@@ -1108,17 +1108,17 @@ func (rl retryerWithLog) ShouldRetry(r *request.Request) bool {
r.Error = errors.New("read tcp *.*.*.*:*->*.*.*.*:*: read: connection reset by peer")
}
})
+ 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
}
if isConnectionRefusedError(r.Error) {
return false
}
- if isDeadlineExceedError(r.Error) && r.HTTPRequest.URL.Host == ec2MetaAddress {
- // fast fail for unreachable linklocal address in EC2 containers.
- log.Warn("failed to get EC2 metadata. skipping.", logutil.ShortError(r.Error))
- return false
- }
return rl.DefaultRetryer.ShouldRetry(r)
}
diff --git a/br/tests/br_full/run.sh b/br/tests/br_full/run.sh
index 78b28d51f8f4e..1753dfdc460d1 100755
--- a/br/tests/br_full/run.sh
+++ b/br/tests/br_full/run.sh
@@ -53,7 +53,7 @@ test_log="${TEST_DIR}/${DB}_test.log"
error_str="not read from or written to within the timeout period"
unset BR_LOG_TO_TERM
-export GO_FAILPOINTS="github.com/pingcap/tidb/br/pkg/backup/backup-storage-error=1*return(\"connection refused\")->1*return(\"InternalError\");github.com/pingcap/tidb/br/pkg/backup/backup-timeout-error=1*return(\"RequestTimeout
\")->1*return(\"not read from or written to within the timeout period\")->1*return(\"InvalidPart
\")""
+export GO_FAILPOINTS="github.com/pingcap/tidb/br/pkg/backup/backup-storage-error=1*return(\"connection refused\")->1*return(\"InternalError\");github.com/pingcap/tidb/br/pkg/backup/backup-timeout-error=1*return(\"RequestTimeout
\")->1*return(\"not read from or written to within the timeout period\")->1*return(\"InvalidPart
\")"
run_br --pd $PD_ADDR backup full -s "local://$TEST_DIR/$DB-lz4" --concurrency 4 --compression lz4 --log-file $test_log
export GO_FAILPOINTS=""
size_lz4=$(du -d 0 $TEST_DIR/$DB-lz4 | awk '{print $1}')