Fixing some cosmetic issues and a potential race condition.

This commit is contained in:
Renan DelValle 2020-05-26 19:55:33 -07:00 committed by Renán I. Del Valle
parent bb5408f5e2
commit f196aa9ed7
3 changed files with 6 additions and 5 deletions

View file

@ -111,7 +111,7 @@ func main() {
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
monitor = &realis.Monitor{r} monitor = &realis.Monitor{Client: r}
defer r.Close() defer r.Close()
switch executor { switch executor {

View file

@ -503,11 +503,12 @@ func basicAuth(username, password string) string {
func (r *realisClient) ReestablishConn() error { func (r *realisClient) ReestablishConn() error {
// Close existing connection // Close existing connection
r.logger.Println("Re-establishing Connection to Aurora") r.logger.Println("Re-establishing Connection to Aurora")
r.Close()
r.lock.Lock() r.lock.Lock()
defer r.lock.Unlock() defer r.lock.Unlock()
r.Close()
// Recreate connection from scratch using original options // Recreate connection from scratch using original options
newRealis, err := NewRealisClient(r.config.options...) newRealis, err := NewRealisClient(r.config.options...)
if err != nil { if err != nil {

View file

@ -137,7 +137,7 @@ func (r *realisClient) thriftCallWithRetries(
} }
r.logger.Printf( 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, adjusted,
curStep) curStep)
@ -154,7 +154,7 @@ func (r *realisClient) thriftCallWithRetries(
resp, clientErr = thriftCall() 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 // Check if our thrift call is returning an error. This is a retryable event as we don't know
@ -162,7 +162,7 @@ func (r *realisClient) thriftCallWithRetries(
if clientErr != nil { if clientErr != nil {
// Print out the error to the user // 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 // Determine if error is a temporary URL error by going up the stack
e, ok := clientErr.(thrift.TTransportException) e, ok := clientErr.(thrift.TTransportException)