Detecting if the transport error was not temporary in which case we stop retrying. Changed bug where get results was being called before we checked for an error.

This commit is contained in:
Renan DelValle 2018-10-29 15:03:27 -07:00
parent 6762c1784b
commit dabd7418a9
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
2 changed files with 37 additions and 22 deletions

View file

@ -16,11 +16,13 @@ package realis
import (
"math/rand"
"net/url"
"time"
"github.com/paypal/gorealis/gen-go/apache/aurora"
"github.com/paypal/gorealis/response"
"github.com/pkg/errors"
"github.com/rdelval/thrift/lib/go/thrift"
)
type Backoff struct {
@ -158,6 +160,19 @@ func (r *realisClient) thriftCallWithRetries(thriftCall auroraThriftCall) (*auro
// Print out the error to the user
r.logger.Printf("Client Error: %v\n", clientErr)
// Determine if error is a temporary URL error by going up the stack
e, ok := clientErr.(thrift.TTransportException)
if ok {
r.logger.DebugPrint("Encountered a transport exception")
e, ok := e.Err().(*url.Error)
if ok {
if !IsTemporary(e) {
return nil, errors.Wrap(clientErr, "Non-temporary connection error")
}
}
}
// In the future, reestablish connection should be able to check if it is actually possible
// to make a thrift call to Aurora. For now, a reconnect should always lead to a retry.
r.ReestablishConn()