From 248a58629bd41e9d7a9f4d863e1fc7e383729976 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 29 Aug 2016 14:25:24 +0300 Subject: [PATCH] MXS-845: Ignore Maintenance state in state change logic When a server goes into maintenance, the current state is set to Maintenance and the previous state is left unmodified. The function which checks for state changes uses the current and previous values and simply compares them. Since servers in maintenance mode aren't monitored, the function always returned true when servers were in maintenance mode. When the state change to or from maintenance is ignored, the state change function works. With this fix, users can safely put servers into maintenance without having to worry about the scripts being executed. This also allows the scripts themselves to put servers into maintenance. --- server/core/monitor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/core/monitor.c b/server/core/monitor.c index 7f229c2bd..b74104aa3 100644 --- a/server/core/monitor.c +++ b/server/core/monitor.c @@ -823,7 +823,9 @@ mon_status_changed(MONITOR_SERVERS* mon_srv) { /* Previous status is -1 if not yet set */ return (mon_srv->mon_prev_status != -1 - && mon_srv->mon_prev_status != mon_srv->server->status); + && 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); } /**