recoverd: Always do an early exit from main_loop if node is stopped or banned
authorAmitay Isaacs <amitay@gmail.com>
Thu, 27 Jun 2013 05:39:15 +0000 (15:39 +1000)
committerMichael Adam <obnox@samba.org>
Mon, 26 Aug 2013 11:35:53 +0000 (13:35 +0200)
A stopped or banned node cannot do anything useful.  So do not participate
in any cluster activity and do not cause any unnecessary network traffic.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 2396981c4bcf30530aeb7f4395093cc202105b50)

server/ctdb_recoverd.c

index 3e9d41374a88645c500478ef72536d85eacbcc8d..a7d2423850f6c83ba552d8adc625743dbe0c1187 100644 (file)
@@ -2990,7 +2990,7 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
        /* if the local daemon is STOPPED or BANNED, we verify that the databases are
           also frozen and thet the recmode is set to active.
        */
-       if (nodemap->nodes[pnn].flags & (NODE_FLAGS_STOPPED | NODE_FLAGS_BANNED)) {
+       if (rec->node_flags & (NODE_FLAGS_STOPPED | NODE_FLAGS_BANNED)) {
                ret = ctdb_ctrl_getrecmode(ctdb, mem_ctx, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, &ctdb->recovery_mode);
                if (ret != 0) {
                        DEBUG(DEBUG_ERR,(__location__ " Failed to read recmode from local node\n"));
@@ -3009,9 +3009,15 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 
                                return;
                        }
-                       return;
                }
+
+               /* If this node is stopped or banned then it is not the recovery
+                * master, so don't do anything. This prevents stopped or banned
+                * node from starting election and sending unnecessary controls.
+                */
+               return;
        }
+
        /* If the local node is stopped, verify we are not the recmaster 
           and yield this role if so
        */
@@ -3085,15 +3091,6 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
                return;
        }
 
-       /* If this node is stopped then it is not the recovery master
-        * so the only remaining action is to potentially to verify
-        * the local IP allocation below.  This won't accomplish
-        * anything useful so skip it.
-        */
-       if (rec->node_flags & NODE_FLAGS_STOPPED) {
-               return;
-       }
-
        /* verify that we have all ip addresses we should have and we dont
         * have addresses we shouldnt have.
         */