Skip to content

Commit

Permalink
Merge pull request PelicanPlatform#1513 from bbockelm/conn_reset
Browse files Browse the repository at this point in the history
Rewrite TCP connection reset / broken pipe messages
  • Loading branch information
turetske authored Jul 25, 2024
2 parents e1b917f + 02010d1 commit d950180
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/errorAccum.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ func IsRetryable(err error) bool {
if errors.Is(err, config.MetadataTimeoutErr) {
return true
}
// There's little a user can do about a TCP connection reset besides retry; if it
// was due to the server crashing, then on a subsequent retry they should get a different
// error message (connection refused).
if errors.Is(err, &NetworkResetError{}) {
return true
}
if errors.Is(err, &StoppedTransferError{}) {
return true
}
Expand Down
11 changes: 11 additions & 0 deletions client/handle_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ type (

HeaderTimeoutError struct{}

NetworkResetError struct{}

allocateMemoryError struct {
Err error
}
Expand Down Expand Up @@ -338,6 +340,10 @@ func (e *HeaderTimeoutError) Error() string {
return "timeout waiting for HTTP response (TCP connection successful)"
}

func (e *NetworkResetError) Error() string {
return "the existing TCP connection was broken (potentially caused by server restart or NAT/firewall issue)"
}

func (e *StoppedTransferError) Error() (errMsg string) {
if e.StoppedTime > 0 {
errMsg = "no progress for more than " + e.StoppedTime.Truncate(time.Millisecond).String()
Expand Down Expand Up @@ -1754,6 +1760,8 @@ func downloadObject(transfer *transferFile) (transferResults TransferResults, er
proxyStr += "(" + ope.Addr.String() + ")"
}
attempt.Error = newTransferAttemptError(serviceStr, proxyStr, true, false, err)
} else if errors.Is(err, syscall.ECONNRESET) || errors.Is(err, syscall.EPIPE) {
attempt.Error = newTransferAttemptError(serviceStr, proxyStr, false, false, &NetworkResetError{})
} else if errors.As(err, &cse) {
if sce, ok := cse.Unwrap().(*StatusCodeError); ok {
attempt.Error = newTransferAttemptError(serviceStr, proxyStr, false, false, sce)
Expand Down Expand Up @@ -2343,6 +2351,9 @@ Loop:
err = &HeaderTimeoutError{}
}
}
if errors.Is(err, syscall.ECONNRESET) || errors.Is(err, syscall.EPIPE) {
err = &NetworkResetError{}
}
lastError = err
break Loop

Expand Down

0 comments on commit d950180

Please sign in to comment.