Skip to content

Commit

Permalink
Fixing some cosmetic issues and a potential race condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
ridv committed May 27, 2020
1 parent bb5408f commit f196aa9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func main() {
if err != nil {
log.Fatalln(err)
}
monitor = &realis.Monitor{r}
monitor = &realis.Monitor{Client: r}
defer r.Close()

switch executor {
Expand Down
3 changes: 2 additions & 1 deletion realis.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,12 @@ func basicAuth(username, password string) string {
func (r *realisClient) ReestablishConn() error {
// Close existing connection
r.logger.Println("Re-establishing Connection to Aurora")
r.Close()

r.lock.Lock()
defer r.lock.Unlock()

r.Close()

// Recreate connection from scratch using original options
newRealis, err := NewRealisClient(r.config.options...)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (r *realisClient) thriftCallWithRetries(
}

r.logger.Printf(
"A retryable error occurred during thrift call, backing off for %v before retry %v\n",
"A retryable error occurred during thrift call, backing off for %v before retry %v",
adjusted,
curStep)

Expand All @@ -154,15 +154,15 @@ func (r *realisClient) thriftCallWithRetries(

resp, clientErr = thriftCall()

r.logger.tracePrintf("Aurora Thrift Call ended resp: %v clientErr: %v\n", resp, clientErr)
r.logger.tracePrintf("Aurora Thrift Call ended resp: %v clientErr: %v", resp, clientErr)
}()

// Check if our thrift call is returning an error. This is a retryable event as we don't know
// if it was caused by network issues.
if clientErr != nil {

// Print out the error to the user
r.logger.Printf("Client Error: %v\n", clientErr)
r.logger.Printf("Client Error: %v", clientErr)

// Determine if error is a temporary URL error by going up the stack
e, ok := clientErr.(thrift.TTransportException)
Expand Down

0 comments on commit f196aa9

Please sign in to comment.