Merge pull request #324 from rj03hou/replication-reset-slave
check the slave status when find recursive find the master, so suppor…
This commit is contained in:
commit
d2f81dfe92
@ -692,6 +692,7 @@ func (this *Inspector) readChangelogState() (map[string]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Inspector) getMasterConnectionConfig() (applierConfig *mysql.ConnectionConfig, err error) {
|
func (this *Inspector) getMasterConnectionConfig() (applierConfig *mysql.ConnectionConfig, err error) {
|
||||||
|
log.Infof("Recursively searching for replication master")
|
||||||
visitedKeys := mysql.NewInstanceKeyMap()
|
visitedKeys := mysql.NewInstanceKeyMap()
|
||||||
return mysql.GetMasterConnectionConfigSafe(this.connectionConfig, visitedKeys, this.migrationContext.AllowedMasterMaster)
|
return mysql.GetMasterConnectionConfigSafe(this.connectionConfig, visitedKeys, this.migrationContext.AllowedMasterMaster)
|
||||||
}
|
}
|
||||||
|
@ -83,12 +83,33 @@ func GetMasterKeyFromSlaveStatus(connectionConfig *ConnectionConfig) (masterKey
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = sqlutils.QueryRowsMap(db, `show slave status`, func(rowMap sqlutils.RowMap) error {
|
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{
|
masterKey = &InstanceKey{
|
||||||
Hostname: rowMap.GetString("Master_Host"),
|
Hostname: rowMap.GetString("Master_Host"),
|
||||||
Port: rowMap.GetInt("Master_Port"),
|
Port: rowMap.GetInt("Master_Port"),
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
return masterKey, err
|
return masterKey, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
localtests/trivial/create.sql
Normal file
13
localtests/trivial/create.sql
Normal file
@ -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');
|
1
localtests/trivial/extra_args
Normal file
1
localtests/trivial/extra_args
Normal file
@ -0,0 +1 @@
|
|||||||
|
--throttle-query='select false' \
|
Loading…
Reference in New Issue
Block a user