{"record":{"id":"46918aa2c5f566c9","repo":"apache/cassandra","slug":"when-reinitializing-with-cluster-metadata-the-sam","errorCode":null,"errorMessage":"When reinitializing with cluster metadata, the same partitioner must be used. Configured: %s, Serialized: %s","messagePattern":"When reinitializing with cluster metadata, the same partitioner must be used\\. Configured: (.+?), Serialized: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/tcm/Startup.java","lineNumber":595,"sourceCode":"        {\n            cmGossip.dumpDiff(initial);\n            throw new AssertionError(\"Issue when populating gossip from cluster metadata\");\n        }\n    }\n\n    public static void reinitializeWithClusterMetadata(String fileName, Function<Processor, Processor> wrapProcessor, Runnable initMessaging) throws IOException, StartupException\n    {\n        ClusterMetadata prev = ClusterMetadata.currentNullable();\n        // First set a minimal ClusterMetadata as some deserialization depends\n        // on ClusterMetadata.current() to access the partitioner\n        StubClusterMetadataService initial = StubClusterMetadataService.forClientTools();\n        ClusterMetadataService.unsetInstance();\n        StubClusterMetadataService.setInstance(initial);\n\n        ClusterMetadata metadata = ClusterMetadataService.deserializeClusterMetadata(fileName);\n        // if the partitioners are mismatching, we probably won't even get this far\n        if (metadata.partitioner != DatabaseDescriptor.getPartitioner())\n            throw new IllegalStateException(String.format(\"When reinitializing with cluster metadata, the same \" +\n                                                          \"partitioner must be used. Configured: %s, Serialized: %s\",\n                                                          DatabaseDescriptor.getPartitioner().getClass().getCanonicalName(),\n                                                          metadata.partitioner.getClass().getCanonicalName()));\n\n        if (!metadata.isCMSMember())\n            throw new IllegalStateException(\"When reinitializing with cluster metadata, we must be in the CMS\");\n\n        metadata = metadata.forceEpoch(metadata.epoch.nextEpoch());\n        ClusterMetadataService.unsetInstance();\n        LocalLog.LogSpec logSpec = LocalLog.logSpec()\n                                           .afterReplay(Startup::scrubDataDirectories,\n                                                        (_metadata) -> StorageService.instance.registerMBeans())\n                                           .withPreviousState(prev)\n                                           .withInitialState(metadata)\n                                           .withStorage(LogStorage.SystemKeyspace)\n                                           .withDefaultListeners()\n                                           .isReset(true);\n","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tcm/Startup.java#L577-L613","documentation":"Startup.reinitializeWithClusterMetadata loads a previously serialized ClusterMetadata snapshot (from a file, typically after restoring node state) and validates it against the current configuration. Since the partitioner determines token and data layout, a serialized metadata whose partitioner differs from DatabaseDescriptor.getPartitioner() cannot be applied; the node throws IllegalStateException naming both partitioner class names. Using mismatched metadata would corrupt token/ring assignments.","triggerScenarios":"reinitializeWithClusterMetadata deserializes metadata via ClusterMetadataService.deserializeClusterMetadata(fileName) and metadata.partitioner != DatabaseDescriptor.getPartitioner(); the snapshot was taken with a different partitioner (e.g. Murmur3Partitioner vs RandomPartitioner) than the current cassandra.yaml partitioner setting.","commonSituations":"Restoring a node/cluster backup into a cluster reconfigured to a different partitioner; copying a metadata dump between clusters (test vs prod) with different partitioner settings; hand-edited cassandra.yaml changing partitioner before reinitialization.","solutions":["Set the partitioner in cassandra.yaml to match the serialized metadata's partitioner (the class name is printed in the error).","Alternatively re-generate/export the cluster metadata snapshot from a cluster running the desired partitioner.","Never switch partitioners on an existing cluster's data — pick one partitioner and keep the snapshot and config aligned.","Verify with the class names in the message (configured vs serialized) which side to change."],"exampleFix":"# before: config mismatches snapshot\npartitioner: org.apache.cassandra.dht.RandomPartitioner   # snapshot is Murmur3Partitioner\n# after:\npartitioner: org.apache.cassandra.dht.Murmur3Partitioner","handlingStrategy":"validation","validationCode":"// before reinitializing, compare partitioners\nif (!metadata.partitioner.getClass().equals(DatabaseDescriptor.getPartitioner().getClass()))\n    throw new ConfigurationException(\"Partitioner mismatch between snapshot and config\");","typeGuard":null,"tryCatchPattern":"try { Startup.reinitializeWithClusterMetadata(fileName); }\ncatch (IllegalStateException e) {\n    if (e.getMessage().contains(\"same partitioner must be used\")) {\n        // align cassandra.yaml partitioner with the snapshot, restart\n    } else throw e;\n}","preventionTips":["Record the partitioner alongside every metadata snapshot","Never change partitioner in an existing cluster's config","Restore snapshots only into like-for-like configurations","Validate config drift between environments before restore"],"tags":["tcm","partitioner","reinitialize","config-mismatch","restore"],"backgroundTag":"config-type-mismatch","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}