MXS-1490: Perform failover only after failcount monitor loops

The same failcount variable is used for the detect_standalone_master-
feature.
This commit is contained in:
Esa Korhonen
2017-11-15 16:41:12 +02:00
parent 703230a930
commit 84d1ea0bff

View File

@ -2884,10 +2884,11 @@ bool mon_process_failover(MYSQL_MONITOR* monitor, uint32_t failover_timeout)
MXS_CONFIG* cnf = config_get_global_options(); MXS_CONFIG* cnf = config_get_global_options();
MXS_MONITORED_SERVER* failed_master = NULL; MXS_MONITORED_SERVER* failed_master = NULL;
if (!cnf->passive)
{
for (MXS_MONITORED_SERVER *ptr = monitor->monitor->monitored_servers; ptr; ptr = ptr->next) for (MXS_MONITORED_SERVER *ptr = monitor->monitor->monitored_servers; ptr; ptr = ptr->next)
{ {
if (ptr->new_event && !cnf->passive && if (ptr->new_event && ptr->server->last_event == MASTER_DOWN_EVENT)
ptr->server->last_event == MASTER_DOWN_EVENT)
{ {
if (failed_master) if (failed_master)
{ {
@ -2903,7 +2904,6 @@ bool mon_process_failover(MYSQL_MONITOR* monitor, uint32_t failover_timeout)
{ {
// MaxScale was active when the event took place // MaxScale was active when the event took place
failed_master = ptr; failed_master = ptr;
ptr->new_event = false;
} }
else if (monitor->monitor->master_has_failed) else if (monitor->monitor->master_has_failed)
{ {
@ -2921,16 +2921,17 @@ bool mon_process_failover(MYSQL_MONITOR* monitor, uint32_t failover_timeout)
"%u seconds, failover needs to be re-triggered", "%u seconds, failover needs to be re-triggered",
ptr->server->unique_name, failover_timeout); ptr->server->unique_name, failover_timeout);
failed_master = ptr; failed_master = ptr;
ptr->new_event = false; }
} }
} }
} }
} }
if (failed_master) if (failed_master && failed_master->mon_err_count >= monitor->failcount)
{ {
MXS_NOTICE("Performing automatic failover to replace failed master '%s'.", MXS_NOTICE("Performing automatic failover to replace failed master '%s'.",
failed_master->server->unique_name); failed_master->server->unique_name);
failed_master->new_event = false;
rval = do_failover(monitor); rval = do_failover(monitor);
} }