recoverd: try to become the recovery master if we have the capability, but the curren...
authorStefan Metzmacher <metze@samba.org>
Tue, 21 Jun 2011 13:49:30 +0000 (15:49 +0200)
committerAmitay Isaacs <amitay@gmail.com>
Tue, 2 Jul 2013 07:41:54 +0000 (17:41 +1000)
metze
(cherry picked from commit 6ba8af28f8a8f79db65120a97d7157dcc5c7e083)

Signed-off-by: Michael Adam <obnox@samba.org>
(cherry picked from commit ccd67cf7f26713e695000d89d9ce8cfa78bfe00f)

server/ctdb_recoverd.c

index 436b496e8235c201449c9c68648dfb2a8099aba8..3fdb44a837758615b09ce27c337b2142ca20af3c 100644 (file)
@@ -3203,6 +3203,13 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
        }
        nodemap = rec->nodemap;
 
+       /* update the capabilities for all nodes */
+       ret = update_capabilities(ctdb, nodemap);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR, (__location__ " Unable to update node capabilities.\n"));
+               return;
+       }
+
        /* check which node is the recovery master */
        ret = ctdb_ctrl_getrecmaster(ctdb, mem_ctx, CONTROL_TIMEOUT(), pnn, &rec->recmaster);
        if (ret != 0) {
@@ -3225,7 +3232,6 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
                return;
        }
 
-
        /* if the local daemon is STOPPED, we verify that the databases are
           also frozen and thet the recmode is set to active 
        */
@@ -3260,6 +3266,21 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
                return;
        }
        
+       /*
+        * if the current recmaster do not have CTDB_CAP_RECMASTER,
+        * but we have force an election and try to become the new
+        * recmaster
+        */
+       if ((rec->ctdb->nodes[rec->recmaster]->capabilities & CTDB_CAP_RECMASTER) == 0 &&
+           (rec->ctdb->capabilities & CTDB_CAP_RECMASTER) &&
+            !(nodemap->nodes[pnn].flags & NODE_FLAGS_INACTIVE)) {
+               DEBUG(DEBUG_ERR, (__location__ " Current recmaster node %u does not have CAP_RECMASTER,"
+                                 " but we (node %u) have - force an election\n",
+                                 rec->recmaster, pnn));
+               force_election(rec, pnn, nodemap);
+               return;
+       }
+
        /* check that we (recovery daemon) and the local ctdb daemon
           agrees on whether we are banned or not
        */