Use change from outbrain/golib PR

This commit is contained in:
Nikhil Mathew 2017-08-28 15:19:05 -07:00
parent 3b21f4db37
commit e4bb70df43
2 changed files with 13 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import (
"github.com/github/gh-ost/go/sql"
"github.com/outbrain/golib/log"
"github.com/outbrain/golib/sqlutils"
)
type ChangelogState string
@ -1225,6 +1226,7 @@ func (this *Migrator) finalCleanup() error {
this.finishedMigrating = true
this.applier.FinalCleanup()
this.eventsStreamer.FinalCleanup()
sqlutils.ResetDBCache()
return nil
}

View File

@ -144,6 +144,17 @@ func GetDB(mysql_uri string) (*sql.DB, bool, error) {
return knownDBs[mysql_uri], exists, nil
}
// Resets the knownDBs cache, used when the DB connections have been closed,
// and new connections are needed to access the DB
func ResetDBCache() {
knownDBsMutex.Lock()
defer func() {
knownDBsMutex.Unlock()
}()
knownDBs = make(map[string]*sql.DB)
}
// RowToArray is a convenience function, typically not called directly, which maps a
// single read database row into a NullString
func RowToArray(rows *sql.Rows, columns []string) []CellData {