{"record":{"id":"59cd3461473a5bb8","repo":"apache/cassandra","slug":"loading-cluster-metadata-from","errorCode":null,"errorMessage":"Loading cluster metadata from {}","messagePattern":"Loading cluster metadata from (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/tcm/ClusterMetadataService.java","lineNumber":593,"sourceCode":"     */\n    public String dumpClusterMetadata(Epoch epoch, Epoch transformToEpoch, Version version) throws IOException\n    {\n        ClusterMetadata toDump = epoch.isAfter(Epoch.EMPTY)\n                                 ? transformSnapshot(LogState.getForRecovery(epoch))\n                                 : ClusterMetadata.current();\n        toDump = toDump.forceEpoch(transformToEpoch);\n        Path p = Files.createTempFile(\"clustermetadata\", \"dump\");\n        try (FileOutputStreamPlus out = new FileOutputStreamPlus(p))\n        {\n            VerboseMetadataSerializer.serialize(ClusterMetadata.serializer, toDump, out, version);\n        }\n        logger.info(\"Dumped cluster metadata to {}\", p.toString());\n        return p.toString();\n    }\n\n    public void loadClusterMetadata(String file) throws IOException\n    {\n        logger.warn(\"Loading cluster metadata from {}\", file);\n        ClusterMetadata metadata = ClusterMetadata.current();\n        ClusterMetadata toApply = deserializeClusterMetadata(file)\n                                  .forceEpoch(metadata.epoch.nextEpoch());\n        forceSnapshot(toApply);\n    }\n\n    public static ClusterMetadata deserializeClusterMetadata(String file) throws IOException\n    {\n        try (FileInputStreamPlus fisp = new FileInputStreamPlus(file))\n        {\n            return VerboseMetadataSerializer.deserialize(ClusterMetadata.serializer, fisp);\n        }\n    }\n\n    private ClusterMetadata transformSnapshot(LogState state)\n    {\n        ClusterMetadata toApply = state.baseState;\n        for (Entry entry : state.entries)","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tcm/ClusterMetadataService.java#L575-L611","documentation":"ClusterMetadataService.loadClusterMetadata logs a warning while importing cluster metadata from a previously dumped file. It deserializes the snapshot, forces a new epoch ahead of the current one, and commits it as a forced snapshot — effectively replacing the cluster's metadata with the file's contents.","triggerScenarios":"An operator calls loadClusterMetadata(file) (exposed via nodetool cms load) to restore metadata from a `cms dump` file.","commonSituations":"Disaster recovery after the TCM log/snapshot was lost or corrupted; recreating a cluster's metadata; migrating metadata between clusters.","solutions":["Ensure the dump file is from the same cluster and era; loading foreign metadata can corrupt topology.","Take a current `nodetool cms dump` before loading for rollback safety.","Confirm all nodes are up and reachable so the forced snapshot commits with quorum.","If the file is unreadable or wrong, re-dump from a healthy node and retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// validate dump file exists and deserializes before applying\nClusterMetadata m = deserializeClusterMetadata(file); // throws IOException if bad\nif (m == null) throw new IOException(\"empty or invalid metadata dump\");","typeGuard":null,"tryCatchPattern":"try { loadClusterMetadata(file); } catch (IOException e) { logger.error(\"metadata load failed; dump file may be corrupt\", e); }","preventionTips":["Only load dumps from the same cluster","Keep pre-load dumps for rollback","Ensure quorum of live nodes before loading"],"tags":["recovery","cluster-metadata","restore"],"backgroundTag":"file-read-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}