[corosync] [PATCH] cpg: Enhance downlist selection algorithm

Jan Friesse jfriesse at redhat.com
Wed Jun 13 14:06:19 GMT 2012


Let's say we have 2 nodes:
- node 2 is paused
- node 1 create membership (one node)
- node 2 is unpaused

Result is that node 1 downlist is selected, so it means that from node 2
point of view, node 1 was never down.

Patch solves situation by adding additional check for largest previous
membership.

So current tests are:
1) largest (previous #nodes - #nodes know to have left)
2) (then) largest previous membership
3) (and last as a tie-breaker) node with smallest nodeid

Signed-off-by: Jan Friesse <jfriesse at redhat.com>
---
 exec/cpg.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/exec/cpg.c b/exec/cpg.c
index 8b883f8..6923812 100644
--- a/exec/cpg.c
+++ b/exec/cpg.c
@@ -811,16 +811,21 @@ static struct downlist_msg* downlist_master_choose (void)
 		best_members = best->old_members - best->left_nodes;
 		cmp_members = cmp->old_members - cmp->left_nodes;
 
-		if (cmp_members < best_members) {
-			continue;
-		}
-		else if (cmp_members > best_members) {
-			best = cmp;
-		}
-		else if (cmp->sender_nodeid < best->sender_nodeid) {
+		if (cmp_members > best_members) {
 			best = cmp;
 		}
 
+		if (cmp_members == best_members) {
+			if (cmp->old_members > best->old_members) {
+				best = cmp;
+			}
+
+			if (cmp->old_members == best->old_members) {
+				if (cmp->sender_nodeid < best->sender_nodeid) {
+					best = cmp;
+				}
+			}
+		}
 	}
 
 	assert (best != NULL);
-- 
1.7.1



More information about the discuss mailing list