{"record":{"id":"ae148a294fc0f964","repo":"apache/cassandra","slug":"unable-to-get-metadata","errorCode":null,"errorMessage":"Unable to get metadata","messagePattern":"Unable to get metadata","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/StressProfile.java","lineNumber":379,"sourceCode":"                tableMetaData = metadata;\n            }\n        }\n    }\n\n    public Set<TokenRange> maybeLoadTokenRanges(StressSettings settings)\n    {\n        maybeLoadSchemaInfo(settings); // ensure table metadata is available\n\n        JavaDriverClient client = settings.getJavaDriverClient(keyspaceName);\n        synchronized (client)\n        {\n            if (tokenRanges != null)\n                return tokenRanges;\n\n            Cluster cluster = client.getCluster();\n            Metadata metadata = cluster.getMetadata();\n            if (metadata == null)\n                throw new RuntimeException(\"Unable to get metadata\");\n\n            List<TokenRange> sortedRanges = new ArrayList<>(metadata.getTokenRanges().size() + 1);\n            for (TokenRange range : metadata.getTokenRanges())\n            {\n                //if we don't unwrap we miss the partitions between ring min and smallest range start value\n                if (range.isWrappedAround())\n                    sortedRanges.addAll(range.unwrap());\n                else\n                    sortedRanges.add(range);\n            }\n\n            Collections.sort(sortedRanges);\n            tokenRanges = new LinkedHashSet<>(sortedRanges);\n            return tokenRanges;\n        }\n    }\n\n    public Operation getQuery(String name,","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/StressProfile.java#L361-L397","documentation":"maybeLoadTokenRanges reads the ring's token ranges from the driver's cluster Metadata. If cluster.getMetadata() returns null (no metadata has been fetched/constructed), a RuntimeException 'Unable to get metadata' is thrown. This typically means the client is not properly connected to the cluster.","triggerScenarios":"Calling getTokenRangeIterator/maybeLoadTokenRanges when the StressCQLClient's Cluster has no Metadata, e.g. driver not fully connected, connection failures at startup, or an offline/misconfigured client.","commonSituations":"Cluster unreachable so the driver never loaded metadata, wrong contact points, node down during stress startup, driver session closed before token ranges are read.","solutions":["Verify the cluster is up and reachable from the stress client (nodetool status, cqlsh connect)","Check contact points/ports in stress settings are correct","Ensure the driver session established before requesting token ranges; restart stress after the cluster recovers","Inspect driver connection logs for metadata/control-connection failures"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure session is connected and metadata is loaded before stress\nsession.getCluster().getMetadata().getAllHosts(); // will throw if control connection failed","typeGuard":"if (cluster.getMetadata() == null) { /* not connected - reconnect */ }","tryCatchPattern":"try { profile.getTokenRangeIterator(...); } catch (RuntimeException e) { if (e.getMessage().contains(\"Unable to get metadata\")) { reconnect(); retryWithBackoff(); } else throw e; }","preventionTips":["Confirm cluster health (nodetool status) before starting stress","Use correct contact points and ports","Keep the driver control connection alive; avoid closing sessions early","Check firewall/network from stress host to the cluster"],"tags":["cassandra","network","metadata"],"backgroundTag":"connection-refused","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"}