diff --git a/go/base/utils.go b/go/base/utils.go index 727bc57..9c47407 100644 --- a/go/base/utils.go +++ b/go/base/utils.go @@ -13,6 +13,7 @@ import ( "time" gosql "database/sql" + "github.com/github/gh-ost/go/mysql" "github.com/outbrain/golib/log" ) @@ -64,7 +65,7 @@ func StringContainsAll(s string, substrings ...string) bool { return nonEmptyStringsFound } -func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig) (string, error) { +func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig, name string) (string, error) { query := `select @@global.port, @@global.version` var port, extraPort int var version string @@ -77,7 +78,7 @@ func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig) } if connectionConfig.Key.Port == port || (extraPort > 0 && connectionConfig.Key.Port == extraPort) { - log.Infof("connection validated on %+v", connectionConfig.Key) + log.Infof("%s connection validated on %+v", name, connectionConfig.Key) return version, nil } else if extraPort == 0 { return "", fmt.Errorf("Unexpected database port reported: %+v", port) diff --git a/go/logic/applier.go b/go/logic/applier.go index 419800d..9e645f4 100644 --- a/go/logic/applier.go +++ b/go/logic/applier.go @@ -34,12 +34,14 @@ type Applier struct { db *gosql.DB singletonDB *gosql.DB migrationContext *base.MigrationContext + name string } func NewApplier() *Applier { return &Applier{ connectionConfig: base.GetMigrationContext().ApplierConnectionConfig, migrationContext: base.GetMigrationContext(), + name: "applier", } } @@ -53,11 +55,11 @@ func (this *Applier) InitDBConnections() (err error) { return err } this.singletonDB.SetMaxOpenConns(1) - version, err := base.ValidateConnection(this.db, this.connectionConfig) + version, err := base.ValidateConnection(this.db, this.connectionConfig, this.name) if err != nil { return err } - if _, err := base.ValidateConnection(this.singletonDB, this.connectionConfig); err != nil { + if _, err := base.ValidateConnection(this.singletonDB, this.connectionConfig, this.name); err != nil { return err } this.migrationContext.ApplierMySQLVersion = version diff --git a/go/logic/inspect.go b/go/logic/inspect.go index 6efacf9..1c18642 100644 --- a/go/logic/inspect.go +++ b/go/logic/inspect.go @@ -29,12 +29,14 @@ type Inspector struct { connectionConfig *mysql.ConnectionConfig db *gosql.DB migrationContext *base.MigrationContext + name string } func NewInspector() *Inspector { return &Inspector{ connectionConfig: base.GetMigrationContext().InspectorConnectionConfig, migrationContext: base.GetMigrationContext(), + name: "inspector", } } @@ -196,7 +198,7 @@ func (this *Inspector) validateConnection() error { return fmt.Errorf("MySQL replication length limited to 32 characters. See https://dev.mysql.com/doc/refman/5.7/en/assigning-passwords.html") } - version, err := base.ValidateConnection(this.db, this.connectionConfig) + version, err := base.ValidateConnection(this.db, this.connectionConfig, this.name) this.migrationContext.InspectorMySQLVersion = version return err } diff --git a/go/logic/streamer.go b/go/logic/streamer.go index 14ac6ab..275af55 100644 --- a/go/logic/streamer.go +++ b/go/logic/streamer.go @@ -43,6 +43,7 @@ type EventsStreamer struct { listenersMutex *sync.Mutex eventsChannel chan *binlog.BinlogEntry binlogReader *binlog.GoMySQLReader + name string } func NewEventsStreamer() *EventsStreamer { @@ -52,6 +53,7 @@ func NewEventsStreamer() *EventsStreamer { listeners: [](*BinlogEventListener){}, listenersMutex: &sync.Mutex{}, eventsChannel: make(chan *binlog.BinlogEntry, EventsChannelBufferSize), + name: "streamer", } } @@ -107,7 +109,7 @@ func (this *EventsStreamer) InitDBConnections() (err error) { if this.db, _, err = sqlutils.GetDB(EventsStreamerUri); err != nil { return err } - if _, err := base.ValidateConnection(this.db, this.connectionConfig); err != nil { + if _, err := base.ValidateConnection(this.db, this.connectionConfig, this.name); err != nil { return err } if err := this.readCurrentBinlogCoordinates(); err != nil {