diff --git a/CHANGES.txt b/CHANGES.txt index 3c47427fb3..658c19f5d9 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) diff --git a/src/java/org/apache/cassandra/gms/Gossiper.java b/src/java/org/apache/cassandra/gms/Gossiper.java index 8c36223986..44e464a8cd 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