ctdb-recoverd: Don't retrieve recovery master from local daemon
authorMartin Schwenke <martin@meltin.net>
Fri, 23 Oct 2015 04:33:01 +0000 (15:33 +1100)
committerAmitay Isaacs <amitay@samba.org>
Mon, 16 Nov 2015 07:42:12 +0000 (08:42 +0100)
The recovery daemon already knows which node is the master.  This
relies on rec->recmaster being correctly initialised and correctly set
during elections.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_recoverd.c

index b01df0aa7a19b1a4d4b11d469599d5115c6aab02..579747638303d74cf18c43e25daf55c64b60bdd6 100644 (file)
@@ -1999,20 +1999,12 @@ static int do_recovery(struct ctdb_recoverd *rec,
        DEBUG(DEBUG_NOTICE, (__location__ " Starting do_recovery\n"));
 
        /* Check if the current node is still the recmaster.  It's possible that
-        * re-election has changed the recmaster, but we have not yet updated
-        * that information.
+        * re-election has changed the recmaster.
         */
-       ret = ctdb_ctrl_getrecmaster(ctdb, mem_ctx, CONTROL_TIMEOUT(),
-                                    pnn, &ctdb->recovery_master);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR, (__location__ " Unable to get recmaster\n"));
-               return -1;
-       }
-
-       if (pnn != ctdb->recovery_master) {
+       if (pnn != rec->recmaster) {
                DEBUG(DEBUG_NOTICE,
                      ("Recovery master changed to %u, aborting recovery\n",
-                      ctdb->recovery_master));
+                      rec->recmaster));
                return -1;
        }
 
@@ -2845,16 +2837,11 @@ static void monitor_handler(uint64_t srvid, TDB_DATA data, void *private_data)
 
        nodemap->nodes[i].flags = c->new_flags;
 
-       ret = ctdb_ctrl_getrecmaster(ctdb, tmp_ctx, CONTROL_TIMEOUT(), 
-                                    CTDB_CURRENT_NODE, &ctdb->recovery_master);
+       ret = ctdb_ctrl_getrecmode(ctdb, tmp_ctx, CONTROL_TIMEOUT(),
+                                  CTDB_CURRENT_NODE, &ctdb->recovery_mode);
 
-       if (ret == 0) {
-               ret = ctdb_ctrl_getrecmode(ctdb, tmp_ctx, CONTROL_TIMEOUT(), 
-                                          CTDB_CURRENT_NODE, &ctdb->recovery_mode);
-       }
-       
        if (ret == 0 &&
-           ctdb->recovery_master == ctdb->pnn &&
+           rec->recmaster == ctdb->pnn &&
            ctdb->recovery_mode == CTDB_RECOVERY_NORMAL) {
                /* Only do the takeover run if the perm disabled or unhealthy
                   flags changed since these will cause an ip failover but not
@@ -2884,19 +2871,11 @@ static void push_flags_handler(uint64_t srvid, TDB_DATA data,
        struct ctdb_node_flag_change *c = (struct ctdb_node_flag_change *)data.dptr;
        struct ctdb_node_map_old *nodemap=NULL;
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
-       uint32_t recmaster;
        uint32_t *nodes;
 
-       /* find the recovery master */
-       ret = ctdb_ctrl_getrecmaster(ctdb, tmp_ctx, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, &recmaster);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR, (__location__ " Unable to get recmaster from local node\n"));
-               talloc_free(tmp_ctx);
-               return;
-       }
-
        /* read the node flags from the recmaster */
-       ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), recmaster, tmp_ctx, &nodemap);
+       ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), rec->recmaster,
+                                  tmp_ctx, &nodemap);
        if (ret != 0) {
                DEBUG(DEBUG_ERR, (__location__ " Unable to get nodemap from node %u\n", c->pnn));
                talloc_free(tmp_ctx);
@@ -3482,13 +3461,6 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
                return;
        }
 
-       /* check which node is the recovery master */
-       ret = ctdb_ctrl_getrecmaster(ctdb, mem_ctx, CONTROL_TIMEOUT(), pnn, &rec->recmaster);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR, (__location__ " Unable to get recmaster from node %u\n", pnn));
-               return;
-       }
-
        /* If we are not the recmaster then do some housekeeping */
        if (rec->recmaster != pnn) {
                /* Ignore any IP reallocate requests - only recmaster