recoverd: do_takeover_run() should mark when a takeover run is in progress
authorMartin Schwenke <martin@meltin.net>
Tue, 3 Sep 2013 01:20:01 +0000 (11:20 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 19 Sep 2013 02:54:30 +0000 (12:54 +1000)
Nested takeover runs should never happens so they should fail.

Signed-off-by: Martin Schwenke <martin@meltin.net>
server/ctdb_recoverd.c

index 32c3fde93e6441d3aeccf5883de6e435ab1686f9..a94fb314313ac3e6796e839329adf01bb3abf321 100644 (file)
@@ -67,6 +67,7 @@ struct ctdb_recoverd {
        struct vacuum_info *vacuum_info;
        TALLOC_CTX *ip_reallocate_ctx;
        struct ip_reallocate_list *reallocate_callers;
+       bool takeover_run_in_progress;
        TALLOC_CTX *ip_check_disable_ctx;
        struct ctdb_control_get_ifaces *ifaces;
        TALLOC_CTX *deferred_rebalance_ctx;
@@ -1586,6 +1587,15 @@ static bool do_takeover_run(struct ctdb_recoverd *rec,
        int ret;
        bool ok;
 
+       if (rec->takeover_run_in_progress) {
+               DEBUG(DEBUG_ERR, (__location__
+                                 " takeover run already in progress \n"));
+               ok = false;
+               goto done;
+       }
+
+       rec->takeover_run_in_progress = true;
+
        ret = ctdb_takeover_run(rec->ctdb, nodemap, takeover_fail_callback,
                                banning_credits_on_fail ? rec : NULL);
        if (ret != 0) {
@@ -1597,6 +1607,7 @@ static bool do_takeover_run(struct ctdb_recoverd *rec,
        ok = true;
 done:
        rec->need_takeover_run = !ok;
+       rec->takeover_run_in_progress = false;
        return ok;
 }
 
@@ -3952,6 +3963,8 @@ static void monitor_cluster(struct ctdb_context *ctdb)
 
        rec->ctdb = ctdb;
 
+       rec->takeover_run_in_progress = false;
+
        rec->priority_time = timeval_current();
 
        /* register a message port for sending memory dumps */