From 568239d2b57d800fa393e923a2a64941fa6b1d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 20 Jan 2017 09:10:44 +0200 Subject: [PATCH] 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. --- server/core/monitor.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/server/core/monitor.c b/server/core/monitor.c index f5f504516..65f4ed517 100644 --- a/server/core/monitor.c +++ b/server/core/monitor.c @@ -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; } /**