MXS-1678: Detect broken replication with Last_IO_Errno
This commit introduces changes that fix the relay master detection that was broken by the merge from 2.1 into 2.2 by commit 1ecd791887994209eb29e56e1271f8c407cd0cdf. In 2.2, the master server ID is used to detect whether a slave is actually replicating from a master. The value is still displayed even if the slave is not actively replicating from a master. The commit in 2.1 causes this value to be stored unconditionally if it is available. By checking the value of Last_IO_Errno and comparing it to a list of known error codes, we know whether the slave is replicating properly. The slave detection in 2.2 correctly identifies a broken slave with a stopped IO thread. Due to this, the test case must be modified to check that the relay master is not a slave if the IO thread is stopped.
This commit is contained in:
@ -1434,7 +1434,12 @@ static bool do_show_slave_status(MYSQL_MONITOR* mon,
|
||||
* root master server.
|
||||
* Please note, there could be no slaves at all if Slave_SQL_Running == 'No'
|
||||
*/
|
||||
if (serv_info->slave_status.slave_io_running && server_version != MYSQL_SERVER_VERSION_51)
|
||||
const char* last_io_errno = mxs_mysql_get_value(result, row, "Last_IO_Errno");
|
||||
int io_errno = last_io_errno ? atoi(last_io_errno) : 0;
|
||||
const int connection_errno = 2003;
|
||||
|
||||
if ((io_errno == 0 || io_errno == connection_errno) &&
|
||||
server_version != MYSQL_SERVER_VERSION_51)
|
||||
{
|
||||
/* Get Master_Server_Id */
|
||||
master_server_id = scan_server_id(row[i_master_server_id]);
|
||||
|
Reference in New Issue
Block a user