From 5112cb4cfc3d1a583f081c9f706595fca116b214 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Tue, 20 Mar 2018 15:46:06 +0200 Subject: [PATCH] MXS-1703: Stop monitor before reading class data In theory, the value of m_master could change between reading it to local variable and stopping monitor. To be on the safe side, stop the monitor first. --- .../mariadbmon/cluster_manipulation.cc | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/server/modules/monitor/mariadbmon/cluster_manipulation.cc b/server/modules/monitor/mariadbmon/cluster_manipulation.cc index bdd14e012..7a1b72a78 100644 --- a/server/modules/monitor/mariadbmon/cluster_manipulation.cc +++ b/server/modules/monitor/mariadbmon/cluster_manipulation.cc @@ -22,22 +22,6 @@ bool MariaDBMonitor::manual_switchover(MXS_MONITORED_SERVER* new_master, MXS_MONITORED_SERVER* given_current_master, json_t** error_out) { - // Autoselect current master if not given as parameter. - MXS_MONITORED_SERVER* current_master = given_current_master; - if (given_current_master == NULL) - { - if (m_master) - { - current_master = m_master; - } - else - { - const char NO_MASTER[] = "Monitor '%s' has no master server."; - PRINT_MXS_JSON_ERROR(error_out, NO_MASTER, m_monitor_base->name); - return false; - } - } - bool stopped = stop(); if (stopped) { @@ -48,7 +32,22 @@ bool MariaDBMonitor::manual_switchover(MXS_MONITORED_SERVER* new_master, MXS_NOTICE("Monitor %s already stopped, switchover can proceed.", m_monitor_base->name); } - bool current_ok = switchover_check_current(current_master, error_out); + // Autoselect current master if not given as parameter. + MXS_MONITORED_SERVER* current_master = given_current_master; + if (current_master == NULL) + { + if (m_master) + { + current_master = m_master; + } + else + { + const char NO_MASTER[] = "Monitor '%s' has no master server."; + PRINT_MXS_JSON_ERROR(error_out, NO_MASTER, m_monitor_base->name); + } + } + + bool current_ok = (current_master != NULL) ? switchover_check_current(current_master, error_out) : false; bool new_ok = switchover_check_new(new_master, error_out); // Check that all slaves are using gtid-replication bool gtid_ok = true;