Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 86E79200B89 for ; Wed, 21 Sep 2016 16:40:35 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 85B07160AE1; Wed, 21 Sep 2016 14:40:35 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A08C5160ABC for ; Wed, 21 Sep 2016 16:40:34 +0200 (CEST) Received: (qmail 57893 invoked by uid 500); 21 Sep 2016 14:40:33 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 57884 invoked by uid 99); 21 Sep 2016 14:40:33 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Sep 2016 14:40:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9F0DFE1772; Wed, 21 Sep 2016 14:40:33 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: clebertsuconic@apache.org To: commits@activemq.apache.org Date: Wed, 21 Sep 2016 14:40:33 -0000 Message-Id: <9d57eb46d046434d8879ddb011b2d49f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] activemq-artemis git commit: ARTEMIS-742 = replication quorum broken archived-at: Wed, 21 Sep 2016 14:40:35 -0000 Repository: activemq-artemis Updated Branches: refs/heads/master 501d127b3 -> 4b5672379 ARTEMIS-742 = replication quorum broken https://issues.apache.org/jira/browse/ARTEMIS-742 Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/680f84b5 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/680f84b5 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/680f84b5 Branch: refs/heads/master Commit: 680f84b5a28b8f1af85640a32c2c0b936a890d5a Parents: 501d127 Author: Andy Taylor Authored: Tue Sep 6 11:49:23 2016 +0100 Committer: Andy Taylor Committed: Wed Sep 21 13:52:36 2016 +0100 ---------------------------------------------------------------------- .../cluster/qourum/QuorumVoteServerConnect.java | 47 ++++++++++---------- .../qourum/SharedNothingBackupQuorum.java | 2 +- 2 files changed, 25 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/680f84b5/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java index 79e41ee..352e5e3 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/QuorumVoteServerConnect.java @@ -31,35 +31,35 @@ public class QuorumVoteServerConnect extends QuorumVote { private static final SimpleString LIVE_FAILOVER_VOTE = new SimpleString("LIVE_FAILOVER)VOTE"); private final CountDownLatch latch; - private double votesNeeded; + private int votesNeeded; private int total = 0; private boolean decision = false; /** - * vote the remaining nodes not including ourself., so - * 1 remaining nodes would be 0/2 = 0 vote needed - * 2 remaining nodes would be 1/2 = 0 vote needed - * 3 remaining nodes would be 2/2 = 1 vote needed - * 4 remaining nodes would be 3/2 = 2 vote needed - * 5 remaining nodes would be 4/2 = 3 vote needed - * 6 remaining nodes would be 5/2 = 3 vote needed + * live nodes | remaining nodes | majority | votes needed + * 1 | 0 | 0 | 0 + * 2 | 1 | 1 | 1 + * n | r = n-1 | n/2 + 1 | n/2 + 1 rounded + * 3 | 2 | 2.5 | 2 + * 4 | 3 | 3 | 3 + * 5 | 4 | 3.5 | 3 + * 6 | 5 | 4 | 4 */ public QuorumVoteServerConnect(int size, StorageManager storageManager) { super(LIVE_FAILOVER_VOTE); - //we don't count ourself - int actualSize = size - 1; - if (actualSize <= 2) { - votesNeeded = actualSize / 2; + double majority; + if (size <= 2) { + majority = ((double)size) / 2; } else { //even - votesNeeded = actualSize / 2 + 1; + majority = ((double)size) / 2 + 1; } //votes needed could be say 2.5 so we add 1 in this case - int latchSize = votesNeeded > (int) votesNeeded ? (int) votesNeeded + 1 : (int) votesNeeded; - latch = new CountDownLatch(latchSize); + votesNeeded = (int) majority; + latch = new CountDownLatch(votesNeeded); if (votesNeeded == 0) { decision = true; } @@ -86,13 +86,14 @@ public class QuorumVoteServerConnect extends QuorumVote { } /** - * vote the remaining nodes not including ourself., so - * 1 remaining nodes would be 0/2 = 0 vote needed - * 2 remaining nodes would be 1/2 = 0 vote needed - * 3 remaining nodes would be 2/2 = 1 vote needed - * 4 remaining nodes would be 3/2 = 2 vote needed - * 5 remaining nodes would be 4/2 = 3 vote needed - * 6 remaining nodes would be 5/2 = 3 vote needed + * live nodes | remaining nodes | majority | votes needed + * 1 | 0 | 0 | 0 + * 2 | 1 | 1 | 1 + * n | r = n-1 | n/2 + 1 | n/2 + 1 rounded + * 3 | 2 | 2.5 | 2 + * 4 | 3 | 3 | 3 + * 5 | 4 | 3.5 | 3 + * 6 | 5 | 4 | 4 * * @param vote the vote to make. */ @@ -102,9 +103,9 @@ public class QuorumVoteServerConnect extends QuorumVote { return; if (vote.getVote()) { total++; + latch.countDown(); if (total >= votesNeeded) { decision = true; - latch.countDown(); } } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/680f84b5/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java index c1bf6a8..5a95791 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/qourum/SharedNothingBackupQuorum.java @@ -252,7 +252,7 @@ public class SharedNothingBackupQuorum implements Quorum, SessionFailureListener */ private boolean isLiveDown() { // we use 1 less than the max cluste size as we arent bothered about the replicated live node - int size = quorumManager.getMaxClusterSize() - 1; + int size = quorumManager.getMaxClusterSize(); QuorumVoteServerConnect quorumVote = new QuorumVoteServerConnect(size, storageManager);