update the "ctdb recover" command.
authorroot <root@test1n1.VSOFS1.COM>
Wed, 10 Dec 2008 01:06:51 +0000 (12:06 +1100)
committerroot <root@test1n1.VSOFS1.COM>
Wed, 10 Dec 2008 01:06:51 +0000 (12:06 +1100)
block and wait until the clustered has completed the recovery before returning.
this  makes it easier to script since it avoids the common need for
   ctdb recover
   ... complex loop to wait for recovery to complete ...
   script continues

(This used to be ctdb commit 8a0df9324a03b0f17772c64a9331236126c22124)

ctdb/tools/ctdb.c

index a005001844b0ff9e63656ddb474ee9962d9c3a51..458331f6b98a5bf52375ff66db6e42e8a07cee4f 100644 (file)
@@ -1433,6 +1433,10 @@ static int control_shutdown(struct ctdb_context *ctdb, int argc, const char **ar
 static int control_recover(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        int ret;
+       uint32_t generation, next_generation;
+
+       /* record the current generation number */
+       generation = get_generation(ctdb);
 
        ret = ctdb_ctrl_freeze(ctdb, TIMELIMIT(), options.pnn);
        if (ret != 0) {
@@ -1446,6 +1450,15 @@ static int control_recover(struct ctdb_context *ctdb, int argc, const char **arg
                return ret;
        }
 
+       /* wait until we are in a new generation */
+       while (1) {
+               next_generation = get_generation(ctdb);
+               if (next_generation != generation) {
+                       return 0;
+               }
+               sleep(1);
+       }
+
        return 0;
 }