Avoid reusing closed DB connection. (#79)

Set DB connection to nil upon closing it.
This commit is contained in:
Oleksii Kliukin
2017-08-10 18:19:35 +02:00
committed by GitHub
parent f15f93f479
commit 87a379f663
+4 -1
View File
@@ -64,7 +64,10 @@ func (c *Cluster) initDbConn() (err error) {
func (c *Cluster) closeDbConn() (err error) {
if c.pgDb != nil {
c.logger.Debug("closing database connection")
return c.pgDb.Close()
if err = c.pgDb.Close(); err != nil {
c.logger.Errorf("could not close database connection: %v", err)
}
c.pgDb = nil
}
c.logger.Warning("attempted to close an empty db connection object")
return nil