tools/ctdb: Do not exit prematurely on control timeout if retrying in a loop
authorAmitay Isaacs <amitay@gmail.com>
Tue, 18 Jun 2013 04:27:34 +0000 (14:27 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 20 Jun 2013 02:56:29 +0000 (12:56 +1000)
This avoids premature exits from "ctdb stop" and "ctdb continue" due to
intermittent control (e.g. getpnn, getnodemap) timeouts.

This needs a proper fix to distinguish between timeout and failure
conditions and take appropriate action.

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

tools/ctdb.c

index c0c346541f8ef48b41453c83fa568a91cddabc5f..5ed378c270868c4648b03cabdf6af8bd9b87eccb 100644 (file)
@@ -1674,7 +1674,8 @@ again:
        /* get the number of nodes and node flags */
        if (ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), options.pnn, ctdb, &nodemap) != 0) {
                DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
-               return -1;
+               sleep(1);
+               goto again;
        }
 
        ipreallocate_finished = false;
@@ -2532,10 +2533,9 @@ static int control_stop(struct ctdb_context *ctdb, int argc, const char **argv)
                /* read the nodemap and verify the change took effect */
                if (ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap) != 0) {
                        DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
-                       exit(10);
                }
 
-       } while (!(nodemap->nodes[options.pnn].flags & NODE_FLAGS_STOPPED));
+       } while (nodemap == NULL || !(nodemap->nodes[options.pnn].flags & NODE_FLAGS_STOPPED));
        ret = control_ipreallocate(ctdb, argc, argv);
        if (ret != 0) {
                DEBUG(DEBUG_ERR, ("IP Reallocate failed on node %u\n", options.pnn));
@@ -2566,10 +2566,9 @@ static int control_continue(struct ctdb_context *ctdb, int argc, const char **ar
                /* read the nodemap and verify the change took effect */
                if (ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap) != 0) {
                        DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
-                       exit(10);
                }
 
-       } while (nodemap->nodes[options.pnn].flags & NODE_FLAGS_STOPPED);
+       } while (nodemap == NULL || nodemap->nodes[options.pnn].flags & NODE_FLAGS_STOPPED);
        ret = control_ipreallocate(ctdb, argc, argv);
        if (ret != 0) {
                DEBUG(DEBUG_ERR, ("IP Reallocate failed on node %u\n", options.pnn));