ctdb-recovery: Update vnnmap before database recovery
authorAmitay Isaacs <amitay@gmail.com>
Fri, 16 Oct 2015 03:45:28 +0000 (14:45 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 16 Oct 2015 07:31:34 +0000 (09:31 +0200)
Once the databases are recovered, all the pending calls are resent.
If the vnnmap is not updated, then the nodes can redirect calls to nodes
that are not part of the new vnnmap.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Fri Oct 16 09:31:34 CEST 2015 on sn-devel-104

ctdb/server/ctdb_recovery_helper.c

index 194b373ad0b9b4fdf397b5b6117fd95439b7f728..6d6a835300da6bab0ad5a09fc12ca1674cd8ee7d 100644 (file)
@@ -1213,9 +1213,9 @@ static bool db_recovery_recv(struct tevent_req *req, int *count)
  * - Get dbmap
  * - Set RECOVERY_ACTIVE
  * - Send START_RECOVERY
+ * - Update vnnmap on all nodes
  * - Run database recovery
  * - Send END_RECOVERY
- * - Update vnnmap on all nodes
  * - Set RECOVERY_NORMAL
  */
 
@@ -1240,8 +1240,8 @@ static void recovery_tunables_done(struct tevent_req *subreq);
 static void recovery_dbmap_done(struct tevent_req *subreq);
 static void recovery_active_done(struct tevent_req *subreq);
 static void recovery_start_recovery_done(struct tevent_req *subreq);
-static void recovery_db_recovery_done(struct tevent_req *subreq);
 static void recovery_vnnmap_update_done(struct tevent_req *subreq);
+static void recovery_db_recovery_done(struct tevent_req *subreq);
 static void recovery_normal_done(struct tevent_req *subreq);
 static void recovery_end_recovery_done(struct tevent_req *subreq);
 
@@ -1600,6 +1600,7 @@ static void recovery_start_recovery_done(struct tevent_req *subreq)
                subreq, struct tevent_req);
        struct recovery_state *state = tevent_req_data(
                req, struct recovery_state);
+       struct ctdb_req_control request;
        int *err_list;
        int ret;
        bool status;
@@ -1627,36 +1628,6 @@ static void recovery_start_recovery_done(struct tevent_req *subreq)
 
        LOG("start_recovery event finished\n");
 
-       subreq = db_recovery_send(state, state->ev, state->client,
-                                 state->dbmap, state->tun_list,
-                                 state->pnn_list, state->count,
-                                 state->vnnmap->generation);
-       if (tevent_req_nomem(subreq, req)) {
-               return;
-       }
-       tevent_req_set_callback(subreq, recovery_db_recovery_done, req);
-}
-
-static void recovery_db_recovery_done(struct tevent_req *subreq)
-{
-       struct tevent_req *req = tevent_req_callback_data(
-               subreq, struct tevent_req);
-       struct recovery_state *state = tevent_req_data(
-               req, struct recovery_state);
-       struct ctdb_req_control request;
-       bool status;
-       int count;
-
-       status = db_recovery_recv(subreq, &count);
-       TALLOC_FREE(subreq);
-
-       LOG("%d databases recovered\n", count);
-
-       if (! status) {
-               tevent_req_error(req, EIO);
-               return;
-       }
-
        ctdb_req_control_setvnnmap(&request, state->vnnmap);
        subreq = ctdb_client_control_multi_send(state, state->ev,
                                                state->client,
@@ -1674,7 +1645,6 @@ static void recovery_vnnmap_update_done(struct tevent_req *subreq)
                subreq, struct tevent_req);
        struct recovery_state *state = tevent_req_data(
                req, struct recovery_state);
-       struct ctdb_req_control request;
        int *err_list;
        int ret;
        bool status;
@@ -1701,6 +1671,36 @@ static void recovery_vnnmap_update_done(struct tevent_req *subreq)
 
        LOG("updated VNNMAP\n");
 
+       subreq = db_recovery_send(state, state->ev, state->client,
+                                 state->dbmap, state->tun_list,
+                                 state->pnn_list, state->count,
+                                 state->vnnmap->generation);
+       if (tevent_req_nomem(subreq, req)) {
+               return;
+       }
+       tevent_req_set_callback(subreq, recovery_db_recovery_done, req);
+}
+
+static void recovery_db_recovery_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct recovery_state *state = tevent_req_data(
+               req, struct recovery_state);
+       struct ctdb_req_control request;
+       bool status;
+       int count;
+
+       status = db_recovery_recv(subreq, &count);
+       TALLOC_FREE(subreq);
+
+       LOG("%d databases recovered\n", count);
+
+       if (! status) {
+               tevent_req_error(req, EIO);
+               return;
+       }
+
        ctdb_req_control_set_recmode(&request, CTDB_RECOVERY_NORMAL);
        subreq = ctdb_client_control_multi_send(state, state->ev,
                                                state->client,