Skip to content

Commit

Permalink
Close opened connections (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwiesel authored Aug 2, 2022
1 parent 335a08c commit 2c653d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/database/maria_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ func purgeBinlogsBefore(c config.DatabaseConfig, minutes int) (err error) {
return
}

defer conn.Close()

if err = conn.Ping(); err != nil {
return
}
Expand Down Expand Up @@ -110,6 +112,8 @@ func purgeBinlogsTo(c config.DatabaseConfig, log string) (err error) {
return
}

defer conn.Close()

if err = conn.Ping(); err != nil {
return
}
Expand All @@ -127,6 +131,8 @@ func resetSlave(c config.DatabaseConfig) (err error) {
return fmt.Errorf("connection for slave reset failed: %s", err.Error())
}

defer conn.Close()

if err = conn.Ping(); err != nil {
return
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/database/mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@ func (m *MariaDB) GetCheckSumForTable(verifyTables []string, withIP bool) (cs Ch
if err != nil {
return
}

defer conn.Close()

if err = conn.Ping(); err != nil {
return
}

defer conn.Close()
m.FlushIncBackup()
rs, err := conn.Execute(fmt.Sprintf("CHECKSUM TABLE %s", strings.Join(verifyTables, ", ")))
if err != nil {
Expand Down

0 comments on commit 2c653d8

Please sign in to comment.