diff --git a/realis.go b/realis.go index 1c7921b..86cc8de 100644 --- a/realis.go +++ b/realis.go @@ -504,11 +504,14 @@ func (r *realisClient) ReestablishConn() error { // Close existing connection r.logger.Println("Re-establishing Connection to Aurora") + // This call must happen before we lock as it also uses + // the same lock from the client since close can be called + // by anyone from anywhere. + 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 {