From 056aac6e0c3b5788a0e89418a43bb778b2984f22 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 16 Oct 2007 12:15:02 +1000 Subject: [PATCH] add a new tunable : DeterministicIPs that makes the allocation of public addresses to nodes deterministic. Activate it by adding CTDB_SET_DeterministicIPs=1 in /etc/sysconfig/ctdb When this is set, the first entry in /etc/ctdb/public_addresses will always be hosted by node 0, when that node is available, the second entry by node1 and so on. This tunable allows the allocation of addresses to become very unbalanced and is only for debugging/testing use. Beware, this feature requires that /etc/ctdb/public_addresses are identical on all the nodes in the cluster. (This used to be ctdb commit f0ca221f235731542090d8a6c86f2b7cd2ce2f96) --- ctdb/include/ctdb_private.h | 1 + ctdb/server/ctdb_takeover.c | 18 ++++++++++++++++++ ctdb/server/ctdb_tunables.c | 1 + 3 files changed, 20 insertions(+) diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index e834f9631fe..3298106d629 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -88,6 +88,7 @@ struct ctdb_tunable { uint32_t database_hash_size; uint32_t rerecovery_timeout; uint32_t enable_bans; + uint32_t deterministic_public_ips; }; /* diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 9986714a17b..ec3455e4c04 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -675,6 +675,17 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap) */ all_ips = create_merged_ip_list(ctdb, tmp_ctx); + /* If we want deterministic ip allocations, i.e. that the ip addresses + will always be allocated the same way for a specific set of + available/unavailable nodes. + */ + if (1 == ctdb->tunable.deterministic_public_ips) { + DEBUG(0,("Deterministic IPs enabled. Resetting all ip allocations\n")); + for (i=0,tmp_ip=all_ips;tmp_ip;tmp_ip=tmp_ip->next,i++) { + tmp_ip->pnn = i%nodemap->num; + } + } + /* mark all public addresses with a masked node as being served by node -1 @@ -759,6 +770,13 @@ try_again: continue; } + /* If we want deterministic IPs then dont try to reallocate + them to spread out the load. + */ + if (1 == ctdb->tunable.deterministic_public_ips) { + continue; + } + /* if the spread between the smallest and largest coverage by a node is >=2 we steal one of the ips from the node with most coverage to even things out a bit. diff --git a/ctdb/server/ctdb_tunables.c b/ctdb/server/ctdb_tunables.c index 7c5aac98007..da1f6e6ba77 100644 --- a/ctdb/server/ctdb_tunables.c +++ b/ctdb/server/ctdb_tunables.c @@ -44,6 +44,7 @@ static const struct { { "DatabaseHashSize", 10000, offsetof(struct ctdb_tunable, database_hash_size) }, { "RerecoveryTimeout", 10, offsetof(struct ctdb_tunable, rerecovery_timeout) }, { "EnableBans", 1, offsetof(struct ctdb_tunable, enable_bans) }, + { "DeterministicIPs", 0, offsetof(struct ctdb_tunable, deterministic_public_ips) }, }; /* -- 2.47.3