MXS-860: Detect whether replication is configured
The `detect_stale_slave` functionality used to only work when MaxScale had the knowledge that a master server has existed and that replication was working at some point in time. This might be a "safe" way to do it in regards to staleness of the data but in practice it is preferrable to always allow slave to be used for reads. This change adds the missing functionality to the monitor by assigning slave status to all servers which are configured as replication slaves when no master can be found. The new member variable that was added to the SERVER should be removed in 2.1 where the server_info offers the same functionalty without "polluting" the SERVER type.
This commit is contained in:
@ -323,8 +323,11 @@ static inline void monitor_mysql100_db(MONITOR_SERVERS* database)
|
||||
return;
|
||||
}
|
||||
|
||||
database->server->slave_configured = false;
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
database->server->slave_configured = true;
|
||||
/* get Slave_IO_Running and Slave_SQL_Running values*/
|
||||
if (strncmp(row[12], "Yes", 3) == 0
|
||||
&& strncmp(row[13], "Yes", 3) == 0)
|
||||
@ -407,8 +410,11 @@ static inline void monitor_mysql55_db(MONITOR_SERVERS* database)
|
||||
return;
|
||||
}
|
||||
|
||||
database->server->slave_configured = false;
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
database->server->slave_configured = true;
|
||||
/* get Slave_IO_Running and Slave_SQL_Running values*/
|
||||
if (strncmp(row[10], "Yes", 3) == 0
|
||||
&& strncmp(row[11], "Yes", 3) == 0)
|
||||
@ -479,8 +485,11 @@ static inline void monitor_mysql51_db(MONITOR_SERVERS* database)
|
||||
return;
|
||||
}
|
||||
|
||||
database->server->slave_configured = false;
|
||||
|
||||
while ((row = mysql_fetch_row(result)))
|
||||
{
|
||||
database->server->slave_configured = true;
|
||||
/* get Slave_IO_Running and Slave_SQL_Running values*/
|
||||
if (strncmp(row[10], "Yes", 3) == 0
|
||||
&& strncmp(row[11], "Yes", 3) == 0)
|
||||
@ -994,6 +1003,11 @@ monitorMain(void *arg)
|
||||
{
|
||||
ptr->pending_status |= SERVER_SLAVE;
|
||||
}
|
||||
else if (root_master == NULL && ptr->server->slave_configured)
|
||||
{
|
||||
/** TODO: Change this in 2.1 to use the server_info mechanism */
|
||||
ptr->pending_status |= SERVER_SLAVE;
|
||||
}
|
||||
}
|
||||
|
||||
ptr->server->status = ptr->pending_status;
|
||||
|
Reference in New Issue
Block a user