diff --git a/go/logic/inspect.go b/go/logic/inspect.go index 4519225..40921cc 100644 --- a/go/logic/inspect.go +++ b/go/logic/inspect.go @@ -692,6 +692,7 @@ func (this *Inspector) readChangelogState() (map[string]string, error) { } func (this *Inspector) getMasterConnectionConfig() (applierConfig *mysql.ConnectionConfig, err error) { + log.Infof("Recursively searching for replication master") visitedKeys := mysql.NewInstanceKeyMap() return mysql.GetMasterConnectionConfigSafe(this.connectionConfig, visitedKeys, this.migrationContext.AllowedMasterMaster) } diff --git a/go/mysql/utils.go b/go/mysql/utils.go index ae22e3a..6b70c7c 100644 --- a/go/mysql/utils.go +++ b/go/mysql/utils.go @@ -83,12 +83,33 @@ func GetMasterKeyFromSlaveStatus(connectionConfig *ConnectionConfig) (masterKey return nil, err } err = sqlutils.QueryRowsMap(db, `show slave status`, func(rowMap sqlutils.RowMap) error { + // We wish to recognize the case where the topology's master actually has replication configuration. + // This can happen when a DBA issues a `RESET SLAVE` instead of `RESET SLAVE ALL`. + + // An empty log file indicates this is a master: + if rowMap.GetString("Master_Log_File") == "" { + return nil + } + + slaveIORunning := rowMap.GetString("Slave_IO_Running") + slaveSQLRunning := rowMap.GetString("Slave_SQL_Running") + + // + if slaveIORunning != "Yes" || slaveSQLRunning != "Yes" { + return fmt.Errorf("Replication on %+v is broken: Slave_IO_Running: %s, Slave_SQL_Running: %s. Please make sure replication runs before using gh-ost.", + connectionConfig.Key, + slaveIORunning, + slaveSQLRunning, + ) + } + masterKey = &InstanceKey{ Hostname: rowMap.GetString("Master_Host"), Port: rowMap.GetInt("Master_Port"), } return nil }) + return masterKey, err } diff --git a/localtests/trivial/create.sql b/localtests/trivial/create.sql new file mode 100644 index 0000000..9371238 --- /dev/null +++ b/localtests/trivial/create.sql @@ -0,0 +1,13 @@ +drop table if exists gh_ost_test; +create table gh_ost_test ( + id int auto_increment, + i int not null, + color varchar(32), + primary key(id) +) auto_increment=1; + +drop event if exists gh_ost_test; + +insert into gh_ost_test values (null, 11, 'red'); +insert into gh_ost_test values (null, 13, 'green'); +insert into gh_ost_test values (null, 17, 'blue'); diff --git a/localtests/trivial/extra_args b/localtests/trivial/extra_args new file mode 100644 index 0000000..8b6320a --- /dev/null +++ b/localtests/trivial/extra_args @@ -0,0 +1 @@ +--throttle-query='select false' \