summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2014-05-06 14:24:52 +1000
committerMartin Schwenke <martins@samba.org>2014-07-07 13:29:49 +0200
commit28a1b75886fb4aea65e23bfd00b9f4c98780fdfd (patch)
tree3976171952276426c7b0cc0c4481cdf6bbfa3228 /ctdb
parent72c6500ee440779819b9adb768a7022cc251f07e (diff)
downloadsamba-28a1b75886fb4aea65e23bfd00b9f4c98780fdfd.tar.gz
ctdb-recoverd: Set recovery mode before freezing databases
Setting recovery mode to active is the only correct way to inform recovery daemon to run database recovery. Only freezing databases without setting recovery mode should not trigger database recovery, as this mechanism is used in tool to implement wipedb/restoredb commands. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/server/ctdb_banning.c2
-rw-r--r--ctdb/server/ctdb_recoverd.c42
2 files changed, 22 insertions, 22 deletions
diff --git a/ctdb/server/ctdb_banning.c b/ctdb/server/ctdb_banning.c
index 13d97c84b13..a9d18910a06 100644
--- a/ctdb/server/ctdb_banning.c
+++ b/ctdb/server/ctdb_banning.c
@@ -70,11 +70,11 @@ void ctdb_local_node_got_banned(struct ctdb_context *ctdb)
*/
ctdb->vnn_map->generation = INVALID_GENERATION;
+ ctdb->recovery_mode = CTDB_RECOVERY_ACTIVE;
for (i=1; i<=NUM_DB_PRIORITIES; i++) {
ctdb_start_freeze(ctdb, i);
}
ctdb_release_all_ips(ctdb);
- ctdb->recovery_mode = CTDB_RECOVERY_ACTIVE;
}
int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata)
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index f553f67715e..ab73e884c28 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -379,8 +379,23 @@ static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_recoverd *re
tmp_ctx = talloc_new(ctdb);
CTDB_NO_MEMORY(ctdb, tmp_ctx);
- /* freeze all nodes */
nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
+
+ data.dsize = sizeof(uint32_t);
+ data.dptr = (unsigned char *)&rec_mode;
+
+ if (ctdb_client_async_control(ctdb, CTDB_CONTROL_SET_RECMODE,
+ nodes, 0,
+ CONTROL_TIMEOUT(),
+ false, data,
+ NULL, NULL,
+ NULL) != 0) {
+ DEBUG(DEBUG_ERR, (__location__ " Unable to set recovery mode. Recovery failed.\n"));
+ talloc_free(tmp_ctx);
+ return -1;
+ }
+
+ /* freeze all nodes */
if (rec_mode == CTDB_RECOVERY_ACTIVE) {
int i;
@@ -399,21 +414,6 @@ static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_recoverd *re
}
}
-
- data.dsize = sizeof(uint32_t);
- data.dptr = (unsigned char *)&rec_mode;
-
- if (ctdb_client_async_control(ctdb, CTDB_CONTROL_SET_RECMODE,
- nodes, 0,
- CONTROL_TIMEOUT(),
- false, data,
- NULL, NULL,
- NULL) != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to set recovery mode. Recovery failed.\n"));
- talloc_free(tmp_ctx);
- return -1;
- }
-
talloc_free(tmp_ctx);
return 0;
}
@@ -3654,17 +3654,17 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
if (ctdb->recovery_mode == CTDB_RECOVERY_NORMAL) {
DEBUG(DEBUG_ERR,("Node is stopped or banned but recovery mode is not active. Activate recovery mode and lock databases\n"));
- ret = ctdb_ctrl_freeze_priority(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, 1);
- if (ret != 0) {
- DEBUG(DEBUG_ERR,(__location__ " Failed to freeze node in STOPPED or BANNED state\n"));
- return;
- }
ret = ctdb_ctrl_setrecmode(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, CTDB_RECOVERY_ACTIVE);
if (ret != 0) {
DEBUG(DEBUG_ERR,(__location__ " Failed to activate recovery mode in STOPPED or BANNED state\n"));
return;
}
+ 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"));
+ return;
+ }
}
/* If this node is stopped or banned then it is not the recovery