MXS-1262: Use monitor journals in all monitors

All monitors now persist the state of the server in a monitor journal
file.

Moved the removal of stale journals into the core and removed them from
the monitor journal interface.
This commit is contained in:
Markus Mäkelä
2017-08-10 08:59:53 +03:00
parent b448b129d0
commit 53bf21f785
8 changed files with 32 additions and 36 deletions

View File

@ -118,6 +118,8 @@ monitorMain(void *arg)
return;
}
load_server_journal(monitor, NULL);
while (!handle->shutdown)
{
lock_monitor_servers(monitor);
@ -141,6 +143,7 @@ monitorMain(void *arg)
mon_process_state_changes(monitor, handle->script, handle->events);
servers_status_current_to_pending(monitor);
store_server_journal(monitor, NULL);
release_monitor_servers(monitor);
/** Sleep until the next monitoring interval */

View File

@ -497,6 +497,7 @@ monitorMain(void *arg)
return;
}
handle->status = MXS_MONITOR_RUNNING;
load_server_journal(mon, NULL);
while (1)
{
@ -651,6 +652,7 @@ monitorMain(void *arg)
update_sst_donor_nodes(mon, is_cluster);
}
store_server_journal(mon, NULL);
release_monitor_servers(mon);
}
}

View File

@ -514,6 +514,8 @@ monitorMain(void *arg)
}
handle->status = MXS_MONITOR_RUNNING;
load_server_journal(mon, &handle->master);
while (1)
{
if (handle->shutdown)
@ -616,6 +618,7 @@ monitorMain(void *arg)
mon_hangup_failed_servers(mon);
servers_status_current_to_pending(mon);
store_server_journal(mon, handle->master);
release_monitor_servers(mon);
}
}

View File

@ -78,7 +78,6 @@ typedef struct
down before failover is initiated */
bool allow_cluster_recovery; /**< Allow failed servers to rejoin the cluster */
bool warn_failover; /**< Log a warning when failover happens */
bool load_journal; /**< Whether journal file should be loaded */
bool allow_external_slaves; /**< Whether to allow usage of external slave servers */
MXS_MONITOR* monitor;
} MYSQL_MONITOR;

View File

@ -244,7 +244,6 @@ startMonitor(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params)
handle->shutdown = 0;
handle->id = config_get_global_options()->id;
handle->warn_failover = true;
handle->load_journal = true;
handle->monitor = monitor;
}
@ -263,12 +262,6 @@ startMonitor(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params)
handle->events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
handle->allow_external_slaves = config_get_bool(params, "allow_external_slaves");
if (journal_is_stale(monitor, monitor->journal_max_age))
{
MXS_WARNING("Removing stale journal file.");
remove_server_journal(monitor);
}
bool error = false;
if (!check_monitor_permissions(monitor, "SHOW SLAVE STATUS"))
@ -1129,7 +1122,9 @@ monitorMain(void *arg)
MXS_ERROR("mysql_thread_init failed in monitor module. Exiting.");
return;
}
handle->status = MXS_MONITOR_RUNNING;
load_server_journal(mon, &handle->master);
while (1)
{
@ -1169,12 +1164,6 @@ monitorMain(void *arg)
lock_monitor_servers(mon);
servers_status_pending_to_current(mon);
if (handle->load_journal)
{
handle->load_journal = false;
load_server_journal(mon, &handle->master);
}
/* start from the first server in the list */
ptr = mon->databases;

View File

@ -316,7 +316,9 @@ monitorMain(void *arg)
MXS_ERROR("Fatal : mysql_thread_init failed in monitor module. Exiting.");
return;
}
handle->status = MXS_MONITOR_RUNNING;
load_server_journal(mon, NULL);
while (1)
{
@ -374,6 +376,7 @@ monitorMain(void *arg)
mon_hangup_failed_servers(mon);
servers_status_current_to_pending(mon);
store_server_journal(mon, NULL);
release_monitor_servers(mon);
}
}