Log only one warning when failover is initiated

Mysqlmon would log a warning at every monitoring interval when failover
was initiated.
This commit is contained in:
Markus Makela 2016-10-06 16:52:50 +03:00
parent 56f0edb247
commit 9b2209a8d1
2 changed files with 8 additions and 1 deletions

View File

@ -77,6 +77,7 @@ typedef struct
bool failover; /**< If simple failover is enabled */
int failcount; /**< How many monitoring cycles servers must be
down before failover is initiated */
bool warn_failover; /**< Log a warning when failover happens */
} MYSQL_MONITOR;
#endif

View File

@ -275,6 +275,7 @@ startMonitor(MONITOR *monitor, const CONFIG_PARAMETER* params)
handle->mysql51_replication = false;
handle->failover = false;
handle->failcount = MYSQLMON_DEFAULT_FAILCOUNT;
handle->warn_failover = true;
memset(handle->events, false, sizeof(handle->events));
spinlock_init(&handle->lock);
}
@ -1093,11 +1094,12 @@ void do_failover(MYSQL_MONITOR *handle, MONITOR_SERVERS *db)
{
if (SERVER_IS_RUNNING(db->server))
{
if (!SERVER_IS_MASTER(db->server))
if (!SERVER_IS_MASTER(db->server) && handle->warn_failover)
{
MXS_WARNING("Failover initiated, server '%s' is now the master. "
"All other servers are set into maintenance mode.",
db->server->unique_name);
handle->warn_failover = false;
}
server_clear_set_status(db->server, SERVER_SLAVE, SERVER_MASTER);
@ -1397,6 +1399,10 @@ monitorMain(void *arg)
/** Other servers have died, initiate a failover to the last remaining server */
do_failover(handle, mon->databases);
}
else
{
handle->warn_failover = true;
}
}
ptr = mon->databases;