[CASSANDRA-20736] Change trigger for UpgradeMigrationListener to merge local node state to gossip

This commit is contained in:
Sam Tunnicliffe 2026-06-08 12:26:14 +01:00
parent 00cd159564
commit fda2d0c02d
2 changed files with 15 additions and 7 deletions

View File

@ -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);

View File

@ -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;