Skip to content

Commit

Permalink
Support downgrading after CMS is initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
beobal committed Dec 16, 2024
1 parent 2ff4155 commit 4fe1388
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public void doVerb(Message<GossipDigestSyn> message)
return;
}

if (gDigestMessage.metadataId != ClusterMetadata.current().metadataIdentifier)
if (gDigestMessage.metadataId != ClusterMetadata.EMPTY_METADATA_IDENTIFIER
&& gDigestMessage.metadataId != ClusterMetadata.current().metadataIdentifier)
{
logger.warn("Cluster metadata identifier mismatch from {} {}!={}", from, gDigestMessage.metadataId, ClusterMetadata.current().metadataIdentifier);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import org.apache.cassandra.gms.VersionedValue;
import org.apache.cassandra.locator.InetAddressAndPort;
import org.apache.cassandra.schema.DistributedSchema;
import org.apache.cassandra.schema.Keyspaces;
import org.apache.cassandra.schema.SchemaConstants;
import org.apache.cassandra.schema.SchemaKeyspace;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.tcm.ClusterMetadata;
Expand Down Expand Up @@ -275,9 +277,15 @@ private static NodeVersion getVersionFromEndpointState(InetAddressAndPort endpoi

public static ClusterMetadata emptyWithSchemaFromSystemTables(Set<String> allKnownDatacenters)
{
// If this instance was previously upgraded then subsequently downgraded, the metadata keyspace may have been
// added to system_schema tables. If so, don't include it in the initial schema as this will cause it to be
// incorrectly configured with the global partitioner. It will be created afresh from
// DistributedMetadataLogKeyspace.initialMetadata.
Keyspaces keyspaces = SchemaKeyspace.fetchNonSystemKeyspaces()
.filter(k -> !k.name.equals(SchemaConstants.METADATA_KEYSPACE_NAME));
return new ClusterMetadata(Epoch.UPGRADE_STARTUP,
DatabaseDescriptor.getPartitioner(),
DistributedSchema.fromSystemTables(SchemaKeyspace.fetchNonSystemKeyspaces(), allKnownDatacenters),
DistributedSchema.fromSystemTables(keyspaces, allKnownDatacenters),
Directory.EMPTY,
new TokenMap(DatabaseDescriptor.getPartitioner()),
DataPlacements.empty(),
Expand Down

0 comments on commit 4fe1388

Please sign in to comment.