tools/ctdb: Add "force" option to "recover" command
authorMartin Schwenke <martin@meltin.net>
Wed, 26 Jun 2013 04:34:47 +0000 (14:34 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Tue, 2 Jul 2013 07:41:54 +0000 (17:41 +1000)
At the moment there is no easy way to force a recovery when attempting
to reproduce certain classes of bugs.  This option is added without
documentation because it is dangerous until the bugs are fixed!  :-)

Signed-off-by: Martin Schwenke <martin@meltin.net>
(cherry picked from commit 4f87925a287f612a6ab3b5da1a387a31c7bea28f)

tools/ctdb.c

index 5ed378c270868c4648b03cabdf6af8bd9b87eccb..b191aadd15875a8a535848dd25fa807b180cac62 100644 (file)
@@ -2759,14 +2759,21 @@ static int control_recover(struct ctdb_context *ctdb, int argc, const char **arg
 {
        int ret;
        uint32_t generation, next_generation;
+       bool force;
+
+       /* "force" option ignores freeze failure and forces recovery */
+       force = (argc == 1) && (strcasecmp(argv[0], "force") == 0);
 
        /* record the current generation number */
        generation = get_generation(ctdb);
 
        ret = ctdb_ctrl_freeze_priority(ctdb, TIMELIMIT(), options.pnn, 1);
        if (ret != 0) {
-               DEBUG(DEBUG_ERR, ("Unable to freeze node\n"));
-               return ret;
+               if (!force) {
+                       DEBUG(DEBUG_ERR, ("Unable to freeze node\n"));
+                       return ret;
+               }
+               DEBUG(DEBUG_WARNING, ("Unable to freeze node but proceeding because \"force\" option given\n"));
        }
 
        ret = ctdb_ctrl_setrecmode(ctdb, TIMELIMIT(), options.pnn, CTDB_RECOVERY_ACTIVE);