MXS-1446: Move failover to mysqlmon
Split the state change processing and failover handling into two separate functions and added a call to the failover function into mysqlmon. This prevents unintended behavior when failover is enabled for non-mysqlmon monitors. The parameter itself still needs to be moved into mysqlmon. Moved the failover documentation to the mysqlmon documentation as it is specific to this monitor.
This commit is contained in:
@ -1728,9 +1728,6 @@ void servers_status_current_to_pending(MXS_MONITOR *monitor)
|
||||
|
||||
void mon_process_state_changes(MXS_MONITOR *monitor, const char *script, uint64_t events)
|
||||
{
|
||||
MXS_CONFIG* cnf = config_get_global_options();
|
||||
MXS_MONITOR_SERVERS* failed_master = NULL;
|
||||
|
||||
for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
|
||||
{
|
||||
if (mon_status_changed(ptr))
|
||||
@ -1752,11 +1749,6 @@ void mon_process_state_changes(MXS_MONITOR *monitor, const char *script, uint64_
|
||||
if (event == MASTER_DOWN_EVENT)
|
||||
{
|
||||
monitor->last_master_down = hkheartbeat;
|
||||
|
||||
if (monitor->failover && !cnf->passive)
|
||||
{
|
||||
failed_master = ptr;
|
||||
}
|
||||
}
|
||||
else if (event == MASTER_UP_EVENT || event == NEW_MASTER_EVENT)
|
||||
{
|
||||
@ -1768,6 +1760,40 @@ void mon_process_state_changes(MXS_MONITOR *monitor, const char *script, uint64_
|
||||
monitor_launch_script(monitor, ptr, script, monitor->script_timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mon_process_failover(MXS_MONITOR *monitor)
|
||||
{
|
||||
MXS_CONFIG* cnf = config_get_global_options();
|
||||
MXS_MONITOR_SERVERS* failed_master = NULL;
|
||||
|
||||
for (MXS_MONITOR_SERVERS *ptr = monitor->databases; ptr; ptr = ptr->next)
|
||||
{
|
||||
if (mon_status_changed(ptr))
|
||||
{
|
||||
if (ptr->server->last_event == MASTER_DOWN_EVENT)
|
||||
{
|
||||
if (monitor->failover && !cnf->passive)
|
||||
{
|
||||
if (failed_master)
|
||||
{
|
||||
MXS_ALERT("Multiple failed master servers detected: "
|
||||
"'%s' is the first master to fail but server "
|
||||
"'%s' has also triggered a master_down event."
|
||||
"Aborting and disabling failover.",
|
||||
failed_master->server->unique_name,
|
||||
ptr->server->unique_name);
|
||||
monitorSetFailover(monitor, false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
failed_master = ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
|
@ -1401,6 +1401,7 @@ monitorMain(void *arg)
|
||||
* need to be launched.
|
||||
*/
|
||||
mon_process_state_changes(mon, handle->script, handle->events);
|
||||
mon_process_failover(mon);
|
||||
|
||||
/* log master detection failure of first master becomes available after failure */
|
||||
if (root_master &&
|
||||
|
Reference in New Issue
Block a user