Adding exception for EOF error. All EOF errors will be retried.

This commit is contained in:
Renan DelValle 2018-10-29 17:29:53 -07:00
parent b66a1422ce
commit f37e455852
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9

View file

@ -15,6 +15,7 @@
package realis package realis
import ( import (
"io"
"math/rand" "math/rand"
"net/url" "net/url"
"time" "time"
@ -90,7 +91,6 @@ func ExponentialBackoff(backoff Backoff, logger Logger, condition ConditionFunc)
} }
if err != nil { if err != nil {
// If the error is temporary, continue retrying. // If the error is temporary, continue retrying.
if !IsTemporary(err) { if !IsTemporary(err) {
return err return err
@ -98,9 +98,7 @@ func ExponentialBackoff(backoff Backoff, logger Logger, condition ConditionFunc)
// Print out the temporary error we experienced. // Print out the temporary error we experienced.
logger.Println(err) logger.Println(err)
} }
} }
} }
if curStep > 1 { if curStep > 1 {
@ -167,8 +165,11 @@ func (r *realisClient) thriftCallWithRetries(thriftCall auroraThriftCall) (*auro
e, ok := e.Err().(*url.Error) e, ok := e.Err().(*url.Error)
if ok { if ok {
if !IsTemporary(e) { // EOF error occurs when the server closes the read buffer of the client. This is common
return nil, errors.Wrap(clientErr, "Non-temporary connection error") // when the server is overloaded and should be retried. All other errors that are permanent
// will not be retried.
if e.Err != io.EOF && !IsTemporary(e) {
return nil, errors.Wrap(clientErr, "Permanent connection error")
} }
} }
} }