[SCM] CTDB repository - branch 1.0.112 updated - ctdb-1.0.111-59-g89d31da

Ronnie Sahlberg sahlberg at samba.org
Wed Apr 7 22:40:07 MDT 2010


The branch, 1.0.112 has been updated
       via  89d31da66ca3f15ed3a87851dea5422be949a2e4 (commit)
      from  7bbf08373eea95d8a859043cf0f9063e77c8c133 (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=1.0.112


- Log -----------------------------------------------------------------
commit 89d31da66ca3f15ed3a87851dea5422be949a2e4
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Apr 8 14:07:57 2010 +1000

    In the recovery daemon, keep track of which node we have assigned public ip
    addresses and verify that the remote nodes have/keep a consistent view of
    assigned addresses.
    
    If a remote node has an inconsistent view of addresses visavi the recovery
    master this will trigger a full ip reallocation.

-----------------------------------------------------------------------

Summary of changes:
 common/rb_tree.h       |   12 +++++-----
 include/ctdb_private.h |    8 ++++++-
 server/ctdb_recoverd.c |   11 ++++++--
 server/ctdb_takeover.c |   57 ++++++++++++++++++++++++++++++++++++++++++------
 4 files changed, 71 insertions(+), 17 deletions(-)


Changeset truncated at 500 lines:

diff --git a/common/rb_tree.h b/common/rb_tree.h
index cb7cba3..eef0bc5 100644
--- a/common/rb_tree.h
+++ b/common/rb_tree.h
@@ -21,17 +21,17 @@
 
 #define TRBT_RED		0x00
 #define TRBT_BLACK		0x01
-typedef struct _trbt_node_t {
-	struct _trbt_tree_t *tree;
-	struct _trbt_node_t *parent;
-	struct _trbt_node_t *left;
-	struct _trbt_node_t *right;
+typedef struct trbt_node {
+	struct trbt_tree *tree;
+	struct trbt_node *parent;
+	struct trbt_node *left;
+	struct trbt_node *right;
 	uint32_t rb_color;
 	uint32_t key32;
 	void *data;
 } trbt_node_t;
 
-typedef struct _trbt_tree_t {
+typedef struct trbt_tree {
 	trbt_node_t *root;
 /* automatically free the tree when the last node has been deleted */
 #define TRBT_AUTOFREE		0x00000001
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index f5e6de8..06985a3 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -439,7 +439,7 @@ struct ctdb_context {
 	struct ctdb_call_state *pending_calls;
 	struct ctdb_client_ip *client_ip_list;
 	bool do_checkpublicip;
-	struct _trbt_tree_t *server_ids;	
+	struct trbt_tree *server_ids;	
 	const char *event_script_dir;
 	const char *notification_script;
 	const char *default_public_interface;
@@ -466,6 +466,9 @@ struct ctdb_context {
 
 	/* mapping from pid to ctdb_client * */
 	struct ctdb_client_pid_list *client_pids;
+
+	/* used in the recovery daemon to remember the ip allocation */
+	struct trbt_tree *ip_tree;
 };
 
 struct ctdb_db_context {
@@ -1561,4 +1564,7 @@ int ctdb_update_persistent_health(struct ctdb_context *ctdb,
 				  int num_healthy_nodes);
 int ctdb_recheck_persistent_health(struct ctdb_context *ctdb);
 
+int verify_remote_ip_allocation(struct ctdb_context *ctdb, 
+				struct ctdb_all_public_ips *ips);
+
 #endif
diff --git a/server/ctdb_recoverd.c b/server/ctdb_recoverd.c
index f94d43b..68f744a 100644
--- a/server/ctdb_recoverd.c
+++ b/server/ctdb_recoverd.c
@@ -2321,9 +2321,9 @@ static enum monitor_result verify_recmaster(struct ctdb_recoverd *rec, struct ct
 }
 
 
-/* called to check that the allocation of public ip addresses is ok.
+/* called to check that the local allocation of public ip addresses is ok.
 */
-static int verify_ip_allocation(struct ctdb_context *ctdb, struct ctdb_recoverd *rec, uint32_t pnn)
+static int verify_local_ip_allocation(struct ctdb_context *ctdb, struct ctdb_recoverd *rec, uint32_t pnn)
 {
 	TALLOC_CTX *mem_ctx = talloc_new(NULL);
 	struct ctdb_all_public_ips *ips = NULL;
@@ -2973,7 +2973,7 @@ again:
 	 */ 
 	if (ctdb->do_checkpublicip) {
 		if (rec->ip_check_disable_ctx == NULL) {
-			if (verify_ip_allocation(ctdb, rec, pnn) != 0) {
+			if (verify_local_ip_allocation(ctdb, rec, pnn) != 0) {
 				DEBUG(DEBUG_ERR, (__location__ " Public IPs were inconsistent.\n"));
 			}
 		}
@@ -3028,6 +3028,11 @@ again:
 				ctdb->nodes[j]->pnn));
 			goto again;
 		}
+
+		if (verify_remote_ip_allocation(ctdb, ctdb->nodes[j]->public_ips)) {
+			DEBUG(DEBUG_ERR,("Node %d has inconsistent public ip allocation and needs update.\n", ctdb->nodes[j]->pnn));
+			rec->need_takeover_run = true;
+		}
 	}
 
 
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index d685de8..acc9ce3 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -686,14 +686,17 @@ void getips_count_callback(void *param, void *data)
 }
 
 struct ctdb_public_ip_list *
-create_merged_ip_list(struct ctdb_context *ctdb, TALLOC_CTX *tmp_ctx)
+create_merged_ip_list(struct ctdb_context *ctdb)
 {
 	int i, j;
 	struct ctdb_public_ip_list *ip_list;
 	struct ctdb_all_public_ips *public_ips;
-	trbt_tree_t *ip_tree;
 
-	ip_tree = trbt_create(tmp_ctx, 0);
+	if (ctdb->ip_tree != NULL) {
+		talloc_free(ctdb->ip_tree);
+		ctdb->ip_tree = NULL;
+	}
+	ctdb->ip_tree = trbt_create(ctdb, 0);
 
 	for (i=0;i<ctdb->num_nodes;i++) {
 		public_ips = ctdb->nodes[i]->public_ips;
@@ -710,13 +713,13 @@ create_merged_ip_list(struct ctdb_context *ctdb, TALLOC_CTX *tmp_ctx)
 		for (j=0;j<public_ips->num;j++) {
 			struct ctdb_public_ip_list *tmp_ip; 
 
-			tmp_ip = talloc_zero(tmp_ctx, struct ctdb_public_ip_list);
+			tmp_ip = talloc_zero(ctdb->ip_tree, struct ctdb_public_ip_list);
 			CTDB_NO_MEMORY_NULL(ctdb, tmp_ip);
 			tmp_ip->pnn  = public_ips->ips[j].pnn;
 			tmp_ip->addr = public_ips->ips[j].addr;
 			tmp_ip->next = NULL;
 
-			trbt_insertarray32_callback(ip_tree,
+			trbt_insertarray32_callback(ctdb->ip_tree,
 				IP_KEYLEN, ip_key(&public_ips->ips[j].addr),
 				add_ip_callback,
 				tmp_ip);
@@ -724,7 +727,7 @@ create_merged_ip_list(struct ctdb_context *ctdb, TALLOC_CTX *tmp_ctx)
 	}
 
 	ip_list = NULL;
-	trbt_traversearray32(ip_tree, IP_KEYLEN, getips_count_callback, &ip_list);
+	trbt_traversearray32(ctdb->ip_tree, IP_KEYLEN, getips_count_callback, &ip_list);
 
 	return ip_list;
 }
@@ -774,8 +777,10 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
 	   a full list of all public addresses that exist in the cluster.
 	   Walk over all node structures and create a merged list of
 	   all public addresses that exist in the cluster.
+
+	   keep the tree of ips around as ctdb->ip_tree
 	*/
-	all_ips = create_merged_ip_list(ctdb, tmp_ctx);
+	all_ips = create_merged_ip_list(ctdb);
 
 	/* If we want deterministic ip allocations, i.e. that the ip addresses
 	   will always be allocated the same way for a specific set of
@@ -2149,3 +2154,41 @@ int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA inda
 	return -1;
 }
 
+/* This function is called from the recovery daemon to verify that a remote
+   node has the expected ip allocation.
+   This is verified against ctdb->ip_tree
+*/
+int verify_remote_ip_allocation(struct ctdb_context *ctdb, struct ctdb_all_public_ips *ips)
+{
+	struct ctdb_public_ip_list *tmp_ip; 
+	int i;
+
+	if (ctdb->ip_tree == NULL) {
+		/* dont know the expected allocation yet, assume remote node
+		   is correct. */
+		return 0;
+	}
+
+	if (ips == NULL) {
+		return 0;
+	}
+
+	for (i=0; i<ips->num; i++) {
+		tmp_ip = trbt_lookuparray32(ctdb->ip_tree, IP_KEYLEN, ip_key(&ips->ips[i].addr));
+		if (tmp_ip == NULL) {
+			DEBUG(DEBUG_ERR,(__location__ " Could not find host for address %s, reassign ips\n", ctdb_addr_to_str(&ips->ips[i].addr)));
+			return -1;
+		}
+
+		if (tmp_ip->pnn == -1 || ips->ips[i].pnn == -1) {
+			continue;
+		}
+
+		if (tmp_ip->pnn != ips->ips[i].pnn) {
+			DEBUG(DEBUG_ERR,("Inconsistent ip allocation. Trigger reallocation.\n"));
+			return -1;
+		}
+	}
+
+	return 0;
+}


-- 
CTDB repository


More information about the samba-cvs mailing list