Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 07F0517888 for ; Thu, 17 Sep 2015 20:07:02 +0000 (UTC) Received: (qmail 77377 invoked by uid 500); 17 Sep 2015 20:06:38 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 77289 invoked by uid 500); 17 Sep 2015 20:06:38 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 76857 invoked by uid 99); 17 Sep 2015 20:06:38 -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; Thu, 17 Sep 2015 20:06:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4EC57E10AE; Thu, 17 Sep 2015 20:06:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: brandonwilliams@apache.org To: commits@cassandra.apache.org Date: Thu, 17 Sep 2015 20:06:44 -0000 Message-Id: In-Reply-To: <0c7301ae746b406eafe159b71cdd03fe@git.apache.org> References: <0c7301ae746b406eafe159b71cdd03fe@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [07/17] cassandra git commit: Fix rare race where older gossip states can be shadowed Fix rare race where older gossip states can be shadowed Patch by brandonwilliams, reviewed by Richard Low for CASSANDRA-10366 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/6f8e07ab Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/6f8e07ab Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/6f8e07ab Branch: refs/heads/cassandra-3.0 Commit: 6f8e07ab06c071cabc20c5cde06122ebf5a5aa78 Parents: 718e47f Author: Brandon Williams Authored: Thu Sep 17 14:58:33 2015 -0500 Committer: Brandon Williams Committed: Thu Sep 17 14:58:33 2015 -0500 ---------------------------------------------------------------------- CHANGES.txt | 1 + src/java/org/apache/cassandra/gms/Gossiper.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/6f8e07ab/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 3c47427..658c19f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.0.17 + * Fix rare race where older gossip states can be shadowed (CASSANDRA-10366) * Fix consolidating racks violating the RF contract (CASSANDRA-10238) * Disallow decommission when node is in drained state (CASSANDRA-8741) * Backport CASSANDRA-8013 to 2.0 (CASSANDRA-10144) http://git-wip-us.apache.org/repos/asf/cassandra/blob/6f8e07ab/src/java/org/apache/cassandra/gms/Gossiper.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/gms/Gossiper.java b/src/java/org/apache/cassandra/gms/Gossiper.java index 8c36223..44e464a 100644 --- a/src/java/org/apache/cassandra/gms/Gossiper.java +++ b/src/java/org/apache/cassandra/gms/Gossiper.java @@ -1139,7 +1139,6 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean localState.setHeartBeatState(remoteState.getHeartBeatState()); if (logger.isTraceEnabled()) logger.trace("Updating heartbeat state version to " + localState.getHeartBeatState().getHeartBeatVersion() + " from " + oldVersion + " for " + addr + " ..."); - // we need to make two loops here, one to apply, then another to notify, this way all states in an update are present and current when the notifications are received for (Entry remoteEntry : remoteState.getApplicationStateMap().entrySet()) { @@ -1385,8 +1384,9 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean logger.trace("Adding saved endpoint " + ep + " " + epState.getHeartBeatState().getGeneration()); } - public void addLocalApplicationState(ApplicationState state, VersionedValue value) + private void addLocalApplicationStateInternal(ApplicationState state, VersionedValue value) { + assert taskLock.isHeldByCurrentThread(); EndpointState epState = endpointStateMap.get(FBUtilities.getBroadcastAddress()); InetAddress epAddr = FBUtilities.getBroadcastAddress(); assert epState != null; @@ -1401,6 +1401,11 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean doOnChangeNotifications(epAddr, state, value); } + public void addLocalApplicationState(ApplicationState applicationState, VersionedValue value) + { + addLocalApplicationStates(Arrays.asList(Pair.create(applicationState, value))); + } + public void addLocalApplicationStates(List> states) { taskLock.lock(); @@ -1408,7 +1413,7 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean { for (Pair pair : states) { - addLocalApplicationState(pair.left, pair.right); + addLocalApplicationStateInternal(pair.left, pair.right); } } finally