Ignore auxiliary server status bits for state changes

The auxiliary status bits for the server were treated as if they changed
the real state of the server. The stale status bits don't affect the real
state of the server so they should be ignored when monitors check for
state changes in servers.
This commit is contained in:
Markus Mäkelä 2017-01-20 09:10:44 +02:00
parent ffc68a688f
commit 568239d2b5

View File

@ -953,14 +953,31 @@ static void mon_append_node_names(MXS_MONITOR_SERVERS* servers, char* dest, int
* @param mon_srv The monitored server
* @return true if status has changed or false
*/
bool
mon_status_changed(MXS_MONITOR_SERVERS* mon_srv)
bool mon_status_changed(MXS_MONITOR_SERVERS* mon_srv)
{
bool rval = false;
/* Previous status is -1 if not yet set */
return (mon_srv->mon_prev_status != -1
&& mon_srv->mon_prev_status != mon_srv->server->status
/** If the server is going into maintenance or coming out of it, don't trigger a state change */
&& ((mon_srv->mon_prev_status | mon_srv->server->status) & SERVER_MAINT) == 0);
if (mon_srv->mon_prev_status != -1)
{
unsigned int relevant_bits = SERVER_RUNNING | SERVER_MASTER | SERVER_SLAVE |
SERVER_JOINED | SERVER_NDB | SERVER_MAINT |
SERVER_SLAVE_OF_EXTERNAL_MASTER | SERVER_RELAY_MASTER;
unsigned int old_status = mon_srv->mon_prev_status & relevant_bits;
unsigned int new_status = mon_srv->server->status & relevant_bits;
/**
* The state has changed if the relevant state bits are not the same and
* the server is not going into maintenance or coming out of it
*/
if (old_status != new_status && ((old_status | new_status) & SERVER_MAINT) == 0)
{
rval = true;
}
}
return rval;
}
/**