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:54:52 +0000 (13:54 +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 f4e30921e7177a0bcab9a73a6b5c0a832a0257c8..fb50d8b6f8a3f70f19c79bf41245f37512ec9c74 100644 (file)
@@ -629,16 +629,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 512a37a55bcaf276e021d0dec1d90a0f8c455a0f..552b66a1577217cfd30c3b98c7b76da856bb2dfb 100644 (file)
@@ -2311,7 +2311,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"));
 
@@ -2331,7 +2331,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"));
 
index fc1dda8643924617c0c2b553fa29b45f116e96fb..3766ed6eb94f013fa22f5b05b26c8acf79ee95b5 100644 (file)
@@ -780,7 +780,6 @@ ctdb_sock_addr *addr)
        data.dsize = sizeof(pip);
        data.dptr  = (unsigned char *)&pip;
 
-
        /* send release ip to all nodes */
        if (ctdb_client_async_control(ctdb, CTDB_CONTROL_RELEASE_IP,
                        list_of_active_nodes(ctdb, nodemap, ctdb, true),
@@ -1700,7 +1699,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;
@@ -2557,7 +2556,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;
@@ -2624,15 +2623,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;
@@ -2642,7 +2644,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) {
@@ -2660,7 +2662,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) {
@@ -2673,7 +2675,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) {
@@ -2688,7 +2690,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) {
@@ -2702,7 +2704,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) {