MXS-1775 Load server journal unconditionally

The server journal is unconditionally loaded and need not be
done in @c pre_loop.
This commit is contained in:
Johan Wikman 2018-06-06 10:23:08 +03:00
parent f600b3a769
commit af717426d5
3 changed files with 24 additions and 4 deletions

View File

@ -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();

View File

@ -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)

View File

@ -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()