Add stale journal file detection

Added a configurable maximum age for the mysqlmon journal files. If the
file is older than the configured value, it will be ignored and removed.
This commit is contained in:
Markus Mäkelä
2017-03-17 13:37:37 +02:00
parent 40b5e627a2
commit bbcfe98651
5 changed files with 89 additions and 24 deletions

View File

@ -53,6 +53,8 @@
#include <maxscale/alloc.h>
#include <maxscale/debug.h>
#define DEFAULT_JOURNAL_MAX_AGE "28800"
/** Column positions for SHOW SLAVE STATUS */
#define MYSQL55_STATUS_BINLOG_POS 5
#define MYSQL55_STATUS_BINLOG_NAME 6
@ -128,6 +130,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
{"detect_standalone_master", MXS_MODULE_PARAM_BOOL, "false"},
{"failcount", MXS_MODULE_PARAM_COUNT, "5"},
{"allow_cluster_recovery", MXS_MODULE_PARAM_BOOL, "true"},
{"journal_max_age", MXS_MODULE_PARAM_COUNT, DEFAULT_JOURNAL_MAX_AGE},
{
"script",
MXS_MODULE_PARAM_PATH,
@ -269,7 +272,7 @@ 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_backup = true;
handle->load_journal = true;
spinlock_init(&handle->lock);
}
@ -286,6 +289,13 @@ startMonitor(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params)
handle->mysql51_replication = config_get_bool(params, "mysql51_replication");
handle->script = config_copy_string(params, "script");
handle->events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
handle->journal_max_age = config_get_integer(params, "journal_max_age");
if (journal_is_stale(monitor, handle->journal_max_age))
{
MXS_WARNING("Removing stale journal file.");
remove_server_journal(monitor);
}
bool error = false;
@ -1099,10 +1109,10 @@ monitorMain(void *arg)
lock_monitor_servers(mon);
servers_status_pending_to_current(mon);
if (handle->load_backup)
if (handle->load_journal)
{
handle->load_backup = false;
load_server_backup(mon);
handle->load_journal = false;
load_server_journal(mon);
}
/* start from the first server in the list */
@ -1382,7 +1392,7 @@ monitorMain(void *arg)
mon_hangup_failed_servers(mon);
servers_status_current_to_pending(mon);
store_server_backup(mon);
store_server_journal(mon);
release_monitor_servers(mon);
} /*< while (1) */
}