Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support downgrading after CMS is initialized #3746

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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