diff --git a/src/java/org/apache/cassandra/gms/Gossiper.java b/src/java/org/apache/cassandra/gms/Gossiper.java index 3d6414913f..8fe8044547 100644 --- a/src/java/org/apache/cassandra/gms/Gossiper.java +++ b/src/java/org/apache/cassandra/gms/Gossiper.java @@ -2234,7 +2234,9 @@ public class Gossiper implements IFailureDetectionEventListener, GossiperMBean, { checkProperThreadForStateMutation(); assert !endpoint.equals(getBroadcastAddressAndPort()) || epstate.getHeartBeatState().getGeneration() > 0 : - "We should not update epstates with generation = 0 for the local host"; + String.format("We should not update epstates with generation = 0 for the local host " + + "(endpoint: %s, broadcast: %s, generation: %s)", + endpoint, getBroadcastAddressAndPort(), epstate.getHeartBeatState().getGeneration()); EndpointState old = endpointStateMap.get(endpoint); if (old == null) endpointStateMap.put(endpoint, epstate); diff --git a/src/java/org/apache/cassandra/tcm/listeners/UpgradeMigrationListener.java b/src/java/org/apache/cassandra/tcm/listeners/UpgradeMigrationListener.java index feb191d32a..5d7e787796 100644 --- a/src/java/org/apache/cassandra/tcm/listeners/UpgradeMigrationListener.java +++ b/src/java/org/apache/cassandra/tcm/listeners/UpgradeMigrationListener.java @@ -47,17 +47,23 @@ public class UpgradeMigrationListener implements ChangeListener logger.info("Detected upgrade from gossip mode"); return; } - else if (prev.epoch.equals(Epoch.FIRST) && !next.directory.isEmpty()) // directory is non-empty after initialization during gossip upgrade + else if (prev.epoch.equals(Epoch.FIRST) && !next.directory.isEmpty()) { NodeId localId = next.myNodeId(); if (localId != null) { - logger.info("Initialized CMS, updating local host id to {}", next.myNodeId()); - SystemKeyspace.setLocalHostId(next.myNodeId().toUUID()); - Gossiper.instance.mergeNodeToGossip(next.myNodeId(), next); + // assigning the local node id is done in Epoch.FIRST in one of two scenarios: + // * during an upgrade from gossip, as all pre-existing nodes will have an id assigned + // * during CMS initialization for a brand new cluster iff the local node is the first CMS member + logger.info("Initialized CMS, updating local host id to {}", localId); + SystemKeyspace.setLocalHostId(localId.toUUID()); + if (Gossiper.instance.isEnabled()) + { + Gossiper.instance.mergeNodeToGossip(localId, next); + if (Gossiper.instance.getQuarantineDisabled()) + Gossiper.instance.clearQuarantinedEndpoints(); + } } - if (Gossiper.instance.getQuarantineDisabled()) - Gossiper.instance.clearQuarantinedEndpoints(); } CassandraVersion prevMinVersion = prev.directory.clusterMinVersion.cassandraVersion;