allow setting the recmode even when not completely frozen.
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 12 Oct 2009 02:06:16 +0000 (13:06 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 12 Oct 2009 02:06:16 +0000 (13:06 +1100)
we sometimes have to do this when we want to trigger a recovery

server/ctdb_recover.c
server/ctdb_recoverd.c
tools/ctdb.c

index 451773dea35f9a02730717ee31d07d32070221a4..40544f14eba661c5e1f64a60c7d474370a6e3bfb 100644 (file)
@@ -642,16 +642,6 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
                event_add_timed(ctdb->ev, ctdb->release_ips_ctx, timeval_current_ofs(ctdb->tunable.recovery_drop_all_ips, 0), ctdb_drop_all_ips_event, ctdb);
        }
 
-
-       for (i=1; i<=NUM_DB_PRIORITIES; i++) {
-               if (ctdb->freeze_mode[i] != CTDB_FREEZE_FROZEN) {
-                       DEBUG(DEBUG_ERR,("Attempt to change recovery mode to %u when not frozen\n", 
-                                recmode));
-                       (*errormsg) = "Cannot change recovery mode while not frozen";
-                       return -1;
-               }
-       }
-
        if (recmode != ctdb->recovery_mode) {
                DEBUG(DEBUG_NOTICE,(__location__ " Recovery mode set to %s\n", 
                         recmode==CTDB_RECOVERY_NORMAL?"NORMAL":"ACTIVE"));
index 879f83db2a6917232e231ce955c358c0ff064f12..a7d07a8b6d1d52fdf9d0e6a165a4456d80e57ad9 100644 (file)
@@ -2294,7 +2294,7 @@ static int verify_ip_allocation(struct ctdb_context *ctdb, uint32_t pnn)
                        if (!ctdb_sys_have_ip(&ips->ips[j].addr)) {
                                DEBUG(DEBUG_CRIT,("Public address '%s' is missing and we should serve this ip\n",
                                        ctdb_addr_to_str(&ips->ips[j].addr)));
-                               ret = ctdb_ctrl_freeze(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE);
+                               ret = ctdb_ctrl_freeze_priority(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 1);
                                if (ret != 0) {
                                        DEBUG(DEBUG_ERR,(__location__ " Failed to freeze node due to public ip address mismatches\n"));
 
@@ -2314,7 +2314,7 @@ static int verify_ip_allocation(struct ctdb_context *ctdb, uint32_t pnn)
                                DEBUG(DEBUG_CRIT,("We are still serving a public address '%s' that we should not be serving.\n", 
                                        ctdb_addr_to_str(&ips->ips[j].addr)));
 
-                               ret = ctdb_ctrl_freeze(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE);
+                               ret = ctdb_ctrl_freeze_priority(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 1);
                                if (ret != 0) {
                                        DEBUG(DEBUG_ERR,(__location__ " Failed to freeze node due to public ip address mismatches\n"));
 
@@ -2790,7 +2790,7 @@ again:
                if (ctdb->recovery_mode == CTDB_RECOVERY_NORMAL) {
                        DEBUG(DEBUG_ERR,("Node is stopped but recovery mode is not active. Activate recovery mode and lock databases\n"));
 
-                       ret = ctdb_ctrl_freeze(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE);
+                       ret = ctdb_ctrl_freeze_priority(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 1);
                        if (ret != 0) {
                                DEBUG(DEBUG_ERR,(__location__ " Failed to freeze node due to node being STOPPED\n"));
                                goto again;
index 97a02e14fbe23dcb7df72557c9ffd8a23a37afe7..0fe044aaf94cc820c39d9ccecca8868ff94c895d 100644 (file)
@@ -913,7 +913,8 @@ static int move_ip(struct ctdb_context *ctdb, ctdb_sock_addr *addr, uint32_t pnn
 
                nodes = list_of_active_nodes_except_pnn(ctdb, nodemap, tmp_ctx, pnn);
        ret = ctdb_client_async_control(ctdb, CTDB_CONTROL_RELEASE_IP,
-                                       nodes, TIMELIMIT(),
+                                       nodes, 0,
+                                       TIMELIMIT(),
                                        false, data,
                                        NULL, NULL,
                                        NULL);
@@ -2047,7 +2048,7 @@ static int control_recover(struct ctdb_context *ctdb, int argc, const char **arg
        /* record the current generation number */
        generation = get_generation(ctdb);
 
-       ret = ctdb_ctrl_freeze(ctdb, TIMELIMIT(), options.pnn);
+       ret = ctdb_ctrl_freeze_priority(ctdb, TIMELIMIT(), options.pnn, 1);
        if (ret != 0) {
                DEBUG(DEBUG_ERR, ("Unable to freeze node\n"));
                return ret;
@@ -3030,7 +3031,7 @@ static int control_restoredb(struct ctdb_context *ctdb, int argc, const char **a
        struct ctdb_db_context *ctdb_db;
        struct ctdb_node_map *nodemap=NULL;
        struct ctdb_vnn_map *vnnmap=NULL;
-       int fh;
+       int i, fh;
        struct ctdb_control_wipe_database w;
        uint32_t *nodes;
        uint32_t generation;
@@ -3097,15 +3098,18 @@ static int control_restoredb(struct ctdb_context *ctdb, int argc, const char **a
 
        /* freeze all nodes */
        nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
-       if (ctdb_client_async_control(ctdb, CTDB_CONTROL_FREEZE,
-                                       nodes, TIMELIMIT(),
+       for (i=1; i<=NUM_DB_PRIORITIES; i++) {
+               if (ctdb_client_async_control(ctdb, CTDB_CONTROL_FREEZE,
+                                       nodes, i,
+                                       TIMELIMIT(),
                                        false, tdb_null,
                                        NULL, NULL,
                                        NULL) != 0) {
-               DEBUG(DEBUG_ERR, ("Unable to freeze nodes.\n"));
-               ctdb_ctrl_setrecmode(ctdb, TIMELIMIT(), options.pnn, CTDB_RECOVERY_ACTIVE);
-               talloc_free(tmp_ctx);
-               return -1;
+                       DEBUG(DEBUG_ERR, ("Unable to freeze nodes.\n"));
+                       ctdb_ctrl_setrecmode(ctdb, TIMELIMIT(), options.pnn, CTDB_RECOVERY_ACTIVE);
+                       talloc_free(tmp_ctx);
+                       return -1;
+               }
        }
 
        generation = vnnmap->generation;
@@ -3115,7 +3119,7 @@ static int control_restoredb(struct ctdb_context *ctdb, int argc, const char **a
        /* start a cluster wide transaction */
        nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_TRANSACTION_START,
-                                       nodes,
+                                       nodes, 0,
                                        TIMELIMIT(), false, data,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -3133,7 +3137,7 @@ static int control_restoredb(struct ctdb_context *ctdb, int argc, const char **a
        /* wipe all the remote databases. */
        nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_WIPE_DATABASE,
-                                       nodes,
+                                       nodes, 0,
                                        TIMELIMIT(), false, data,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -3146,7 +3150,7 @@ static int control_restoredb(struct ctdb_context *ctdb, int argc, const char **a
        /* push the database */
        nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_PUSH_DB,
-                                       nodes,
+                                       nodes, 0,
                                        TIMELIMIT(), false, outdata,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -3161,7 +3165,7 @@ static int control_restoredb(struct ctdb_context *ctdb, int argc, const char **a
 
        /* commit all the changes */
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_TRANSACTION_COMMIT,
-                                       nodes,
+                                       nodes, 0,
                                        TIMELIMIT(), false, data,
                                        NULL, NULL,
                                        NULL) != 0) {
@@ -3175,7 +3179,8 @@ static int control_restoredb(struct ctdb_context *ctdb, int argc, const char **a
        /* thaw all nodes */
        nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_THAW,
-                                       nodes, TIMELIMIT(),
+                                       nodes, 0,
+                                       TIMELIMIT(),
                                        false, tdb_null,
                                        NULL, NULL,
                                        NULL) != 0) {