Skip to content

Commit

Permalink
Avoid reusing closed DB connection.
Browse files Browse the repository at this point in the history
Set DB connection to nil upon closing it.
  • Loading branch information
alexeyklyukin committed Aug 10, 2017
1 parent c314b9f commit 7871158
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/cluster/pg.go
Expand Up @@ -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
Expand Down

0 comments on commit 7871158

Please sign in to comment.