stopped nodes can not win a recmaster election
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 9 Jul 2009 04:44:03 +0000 (14:44 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 9 Jul 2009 04:44:03 +0000 (14:44 +1000)
stopped nodes must yield the recmaster role

server/ctdb_recoverd.c

index 8f6106f614dbc6e3d335c3723360f462c8091e3b..d601ca60a82f0e63eb66e9efc5d806206833e327 100644 (file)
@@ -1660,11 +1660,21 @@ static bool ctdb_election_win(struct ctdb_recoverd *rec, struct election_message
                return false;
        }       
 
+       /* we cant win if we are stopped */
+       if (rec->node_flags & NODE_FLAGS_STOPPED) {
+               return false;
+       }       
+
        /* we will automatically win if the other node is banned */
        if (em->node_flags & NODE_FLAGS_BANNED) {
                return true;
        }
 
+       /* we will automatically win if the other node is banned */
+       if (em->node_flags & NODE_FLAGS_STOPPED) {
+               return true;
+       }
+
        /* try to use the most connected node */
        if (cmp == 0) {
                cmp = (int)myem.num_connected - (int)em->num_connected;
@@ -2831,7 +2841,14 @@ again:
                        goto again;
                }
        }
-
+       /* If the local node is stopped, verify we are not the recmaster 
+          and yield this role if so
+       */
+       if ((nodemap->nodes[pnn].flags & NODE_FLAGS_STOPPED) && (rec->recmaster == pnn)) {
+               DEBUG(DEBUG_ERR,("Local node is STOPPED. Yielding recmaster role\n"));
+               force_election(rec, pnn, nodemap);
+               goto again;
+       }
        
        /* check that we (recovery daemon) and the local ctdb daemon
           agrees on whether we are banned or not