ctdb-recoverd: Freeze databases whenever the node is INACTIVE bob
authorAmitay Isaacs <amitay@gmail.com>
Wed, 1 Jun 2016 02:10:46 +0000 (12:10 +1000)
committerMichael Adam <obnox@samba.org>
Wed, 1 Jun 2016 02:23:57 +0000 (04:23 +0200)
If the node becomes stopped or banned after recovery is marked active,
then it will never freeze the databases.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_recoverd.c

index 09940dc32f881b05a277b5299510fa9bf576e8f0..cb5f8a34fd78a43fe38a3e1a252b30c02573e87d 100644 (file)
@@ -257,6 +257,7 @@ struct ctdb_recoverd {
        struct ctdb_iface_list_old *ifaces;
        uint32_t *force_rebalance_nodes;
        struct ctdb_node_capabilities *caps;
+       bool frozen_on_inactive;
 };
 
 #define CONTROL_TIMEOUT() timeval_current_ofs(ctdb->tunable.recover_timeout, 0)
@@ -3550,11 +3551,18 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 
                                return;
                        }
-                       ret = ctdb_ctrl_freeze(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE);
+               }
+               if (! rec->frozen_on_inactive) {
+                       ret = ctdb_ctrl_freeze(ctdb, CONTROL_TIMEOUT(),
+                                              CTDB_CURRENT_NODE);
                        if (ret != 0) {
-                               DEBUG(DEBUG_ERR,(__location__ " Failed to freeze node in STOPPED or BANNED state\n"));
+                               DEBUG(DEBUG_ERR,
+                                     (__location__ " Failed to freeze node "
+                                      "in STOPPED or BANNED state\n"));
                                return;
                        }
+
+                       rec->frozen_on_inactive = true;
                }
 
                /* If this node is stopped or banned then it is not the recovery
@@ -3564,6 +3572,8 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
                return;
        }
 
+       rec->frozen_on_inactive = false;
+
        /* Retrieve capabilities from all connected nodes */
        ret = update_capabilities(rec, nodemap);
        if (ret != 0) {
@@ -3901,6 +3911,7 @@ static void monitor_cluster(struct ctdb_context *ctdb)
        CTDB_NO_MEMORY_FATAL(ctdb, rec->recovery);
 
        rec->priority_time = timeval_current();
+       rec->frozen_on_inactive = false;
 
        /* register a message port for sending memory dumps */
        ctdb_client_set_message_handler(ctdb, CTDB_SRVID_MEM_DUMP, mem_dump_handler, rec);