From 49fe66713fbf01b83cdee09e26d5e3641039d81a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 May 2007 23:23:41 +1000 Subject: [PATCH] - don't try to send controls to dead nodes - use only connected nodes in a traverse (This used to be ctdb commit 9a676dd5d331022d946a56c52c42fc6985b93dbc) --- ctdb/common/ctdb.c | 15 +++++++++++++++ ctdb/common/ctdb_control.c | 9 +++++++++ ctdb/common/ctdb_recoverd.c | 4 ++-- ctdb/common/ctdb_traverse.c | 2 +- ctdb/include/ctdb.h | 8 +++++++- ctdb/include/ctdb_private.h | 2 ++ 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/ctdb/common/ctdb.c b/ctdb/common/ctdb.c index 9fd967d8e62..15b2f06109d 100644 --- a/ctdb/common/ctdb.c +++ b/ctdb/common/ctdb.c @@ -217,6 +217,21 @@ uint32_t ctdb_get_num_nodes(struct ctdb_context *ctdb) return ctdb->num_nodes; } +/* + return the number of connected nodes +*/ +uint32_t ctdb_get_num_connected_nodes(struct ctdb_context *ctdb) +{ + int i; + uint32_t count=0; + for (i=0;ivnn_map->size;i++) { + if (ctdb->nodes[i]->flags & NODE_FLAGS_CONNECTED) { + count++; + } + } + return count; +} + /* called by the transport layer when a packet comes in diff --git a/ctdb/common/ctdb_control.c b/ctdb/common/ctdb_control.c index bc57a94b3c5..3c3a6d17d36 100644 --- a/ctdb/common/ctdb_control.c +++ b/ctdb/common/ctdb_control.c @@ -395,6 +395,15 @@ int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode, return -1; } + if (destnode != CTDB_BROADCAST_VNNMAP && destnode != CTDB_BROADCAST_VNNMAP && + (!ctdb_validate_vnn(ctdb, destnode) || + !(ctdb->nodes[destnode]->flags & NODE_FLAGS_CONNECTED))) { + if (!(flags & CTDB_CTRL_FLAG_NOREPLY)) { + callback(ctdb, -1, tdb_null, "ctdb_control to disconnected node", private_data); + } + return 0; + } + /* the state is made a child of private_data if possible. This means any reply will be discarded if the private_data goes away */ state = talloc(private_data?private_data:ctdb, struct ctdb_control_state); diff --git a/ctdb/common/ctdb_recoverd.c b/ctdb/common/ctdb_recoverd.c index 9b5d04eb98f..c813e69f168 100644 --- a/ctdb/common/ctdb_recoverd.c +++ b/ctdb/common/ctdb_recoverd.c @@ -447,6 +447,8 @@ static int do_recovery(struct ctdb_context *ctdb, return -1; } + /* send a message to all clients telling them that the cluster has been reconfigured */ + ctdb_send_message(ctdb, CTDB_BROADCAST_ALL, CTDB_SRVID_RECONFIGURE, tdb_null); DEBUG(0, (__location__ " Recovery complete\n")); return 0; @@ -465,7 +467,6 @@ static int send_election_request(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, uint64_t srvid; srvid = CTDB_SRVTYPE_RECOVERY; - srvid <<= 32; emsg.vnn = vnn; @@ -857,7 +858,6 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb) /* register a message port for recovery elections */ srvid = CTDB_SRVTYPE_RECOVERY; - srvid <<= 32; ctdb_set_message_handler(ctdb, srvid, election_handler, NULL); monitor_cluster(ctdb); diff --git a/ctdb/common/ctdb_traverse.c b/ctdb/common/ctdb_traverse.c index 00c3c1b66e0..53504215a4d 100644 --- a/ctdb/common/ctdb_traverse.c +++ b/ctdb/common/ctdb_traverse.c @@ -365,7 +365,7 @@ int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb, TDB_DATA data, TDB if (key.dsize == 0 && data.dsize == 0) { state->null_count++; - if (state->null_count != ctdb_get_num_nodes(ctdb)) { + if (state->null_count != ctdb_get_num_connected_nodes(ctdb)) { return 0; } } diff --git a/ctdb/include/ctdb.h b/ctdb/include/ctdb.h index 782fda9f336..a330f709a51 100644 --- a/ctdb/include/ctdb.h +++ b/ctdb/include/ctdb.h @@ -56,10 +56,16 @@ struct ctdb_call_info { a message handler ID meaning "give me all messages" */ #define CTDB_SRVID_ALL (~(uint64_t)0) + /* srvid type : RECOVERY */ -#define CTDB_SRVTYPE_RECOVERY 0x64766372 +#define CTDB_SRVTYPE_RECOVERY 0xF100000000000000LL + +/* + a message handler ID meaning that the cluster has been reconfigured + */ +#define CTDB_SRVID_RECONFIGURE 0xF200000000000000LL struct event_context; diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index b0cd59d823f..3188c51a607 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -802,4 +802,6 @@ int32_t ctdb_control_thaw(struct ctdb_context *ctdb); int ctdb_start_recoverd(struct ctdb_context *ctdb); +uint32_t ctdb_get_num_connected_nodes(struct ctdb_context *ctdb); + #endif -- 2.47.3