Skip to content

Commit

Permalink
br: stop s3 retryer when connection is refused (#46938)
Browse files Browse the repository at this point in the history
ref #46258
  • Loading branch information
tangenta authored Sep 13, 2023
1 parent 1e4b2d2 commit a7e3176
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions br/pkg/storage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,10 @@ func isConnectionResetError(err error) bool {
return strings.Contains(err.Error(), "read: connection reset")
}

func isConnectionRefusedError(err error) bool {
return strings.Contains(err.Error(), "connection refused")
}

func (rl retryerWithLog) ShouldRetry(r *request.Request) bool {
// for unit test
failpoint.Inject("replace-error-to-connection-reset-by-peer", func(_ failpoint.Value) {
Expand All @@ -1024,6 +1028,9 @@ func (rl retryerWithLog) ShouldRetry(r *request.Request) bool {
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))
Expand Down

0 comments on commit a7e3176

Please sign in to comment.