diff --git a/include/maxscale/monitor.hh b/include/maxscale/monitor.hh index 425d8367e..92912a0fb 100644 --- a/include/maxscale/monitor.hh +++ b/include/maxscale/monitor.hh @@ -62,6 +62,18 @@ public: * - Calls @c configure(). * - Starts the monitor thread. * + * - Once the monitor thread starts, it will + * - Load the server journal and update @c m_master. + * - Call @c pre_loop(). + * - Enter a loop where it, until told to shut down, will + * - Check whether there are maintenance requests. + * - Call @c tick(). + * - Call @c process_state_changes() + * - Hang up failed servers. + * - Store the server journal (@c m_master assumed to reflect the current situation). + * - Sleep until time for next @c tick(). + * - Call @c post_loop(). + * * @param param The parameters of the monitor. * * @return True, if the monitor started, false otherwise. @@ -198,7 +210,7 @@ protected: /** * @brief Called before the monitor loop is started * - * The default implementation will load the journal and update @c m_master. + * The default implementation does nothing. */ virtual void pre_loop(); diff --git a/server/core/monitor.cc b/server/core/monitor.cc index dad67e340..9f6940b51 100644 --- a/server/core/monitor.cc +++ b/server/core/monitor.cc @@ -2899,7 +2899,6 @@ void MonitorInstance::tick() void MonitorInstance::pre_loop() { - load_server_journal(m_monitor, &m_master); } void MonitorInstance::post_loop() @@ -2913,6 +2912,8 @@ void MonitorInstance::process_state_changes() void MonitorInstance::main() { + load_server_journal(m_monitor, &m_master); + pre_loop(); while (!m_shutdown) diff --git a/server/modules/monitor/mariadbmon/mariadbmon.cc b/server/modules/monitor/mariadbmon/mariadbmon.cc index d6ae19b77..fbb260d10 100644 --- a/server/modules/monitor/mariadbmon/mariadbmon.cc +++ b/server/modules/monitor/mariadbmon/mariadbmon.cc @@ -283,8 +283,9 @@ void MariaDBMonitor::update_server_status(MXS_MONITORED_SERVER* monitored_server void MariaDBMonitor::pre_loop() { - MonitorInstance::pre_loop(); - + // MonitorInstance loaded from the journal the current master into its + // m_master member variable, we want the corresponding MariaDBServer into + // our own m_master varaible. m_master = MonitorInstance::m_master ? get_server_info(MonitorInstance::m_master) : NULL; if (m_detect_replication_lag) @@ -414,6 +415,12 @@ void MariaDBMonitor::tick() /* log master detection failure of first master becomes available after failure */ log_master_changes(root_master); + + // Before exiting we need to store the current master into the m_master + // member variable of MonitorInstance so tga loaded from the journal the current master into its + // m_master member variable, we want the corresponding MariaDBServer into + // our own m_master varaible. + MonitorInstance::m_master = m_master ? m_master->m_server_base : NULL; } void MariaDBMonitor::process_state_changes()