{"record":{"id":"0f7dd372d2a7d21e","repo":"apache/cassandra","slug":"problem-opening-token-allocation-keyspace-allo","errorCode":null,"errorMessage":"Problem opening token allocation keyspace \" + allocationKeyspace","messagePattern":"Problem opening token allocation keyspace \" \\+ allocationKeyspace","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/dht/BootStrapper.java","lineNumber":277,"sourceCode":"        List<Token> tokens = new ArrayList<>(initialTokens.size());\n        for (String tokenString : initialTokens)\n        {\n            Token token = metadata.tokenMap.partitioner().getTokenFactory().fromString(tokenString);\n            if (metadata.tokenMap.owner(token) != null)\n                throw new ConfigurationException(\"Bootstrapping to existing token \" + tokenString + \" is not allowed (decommission/removenode the old node first).\");\n            tokens.add(token);\n        }\n        return tokens;\n    }\n\n    static Collection<Token> allocateTokens(final ClusterMetadata metadata,\n                                            InetAddressAndPort address,\n                                            String allocationKeyspace,\n                                            int numTokens)\n    {\n        Keyspace ks = Keyspace.open(allocationKeyspace);\n        if (ks == null)\n            throw new ConfigurationException(\"Problem opening token allocation keyspace \" + allocationKeyspace);\n        AbstractReplicationStrategy rs = ks.getReplicationStrategy();\n\n        Collection<Token> tokens = TokenAllocation.allocateTokens(metadata, rs, address, numTokens);\n        BootstrapDiagnostics.tokensAllocated(address, metadata, allocationKeyspace, numTokens, tokens);\n        return tokens;\n    }\n\n\n    static Collection<Token> allocateTokens(final ClusterMetadata metadata,\n                                            InetAddressAndPort address,\n                                            int rf,\n                                            int numTokens)\n    {\n        Collection<Token> tokens = TokenAllocation.allocateTokens(metadata, rf, address, numTokens);\n        BootstrapDiagnostics.tokensAllocated(address, metadata, rf, numTokens, tokens);\n        return tokens;\n    }\n","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/dht/BootStrapper.java#L259-L295","documentation":"BootStrapper.allocateTokens opens the keyspace whose replication is used to allocate a new node's tokens and throws ConfigurationException when Keyspace.open returns null, i.e. the named keyspace does not exist. Token allocation via TokenAllocatorFactory requires a real keyspace to compute ownership, so without it bootstrap cannot proceed. This happens only when an explicit allocation keyspace was configured (allocate_tokens_for_local_replication_factor / allocationKeyspace).","triggerScenarios":"Calling BootStrapper.allocateTokens(metadata, address, allocationKeyspace, numTokens) where allocationKeyspace names a keyspace that does not exist in the schema; bootstrap startup with allocate_tokens_for_local_replication_factor set to a keyspace that was never created on this node (schema not yet propagated or typo in the name).","commonSituations":"cassandra.yaml has allocate_tokens_for_local_replication_factor pointing to a keyspace only created by an application after startup; typo or case mismatch in the keyspace name; bootstrapping a node before the schema (auth keyspaces aside) has agreed cluster-wide; using a keyspace name from a different cluster.","solutions":["Create the named keyspace (or correct cassandra.yaml allocate_tokens_for_local_replication_factor / the allocationKeyspace argument to an existing keyspace) before bootstrapping.","Wait for schema agreement (system.schema_* / schema versions match) if the keyspace exists elsewhere in the cluster but was not yet propagated to this node.","Remove allocate_tokens_for_local_replication_factor to fall back to random token allocation if you don't need allocation-aware tokens.","Verify keyspace name spelling/case with cqlsh: DESCRIBE KEYSPACES."],"exampleFix":"// before (cassandra.yaml)\nallocate_tokens_for_local_replication_factor: 3  # keyspace 'app_ks' not created yet\n// after\n# create keyspace first, then bootstrap:\n# CREATE KEYSPACE app_ks WITH replication = {'class':'NetworkTopologyStrategy','dc1':3};\nallocate_tokens_for_local_replication_factor: 3","handlingStrategy":"validation","validationCode":"String ksName = allocationKeyspace;\nif (Schema.instance.getKeyspaceMetadata(ksName) == null)\n    throw new IllegalStateException(\"Keyspace '\" + ksName + \"' must exist before token allocation/bootstrap\");","typeGuard":"boolean allocationKeyspaceUsable(String ks) { return ks != null && Schema.instance.getKeyspaceMetadata(ks) != null; }","tryCatchPattern":"try {\n    tokens = BootStrapper.allocateTokens(metadata, address, ks, numTokens);\n} catch (ConfigurationException e) {\n    logger.error(\"Allocation keyspace unavailable: {}\", e.getMessage());\n    // fall back to random tokens or abort bootstrap\n}","preventionTips":["Create the allocation keyspace via cqlsh before bootstrapping nodes that use allocate_tokens_for_local_replication_factor.","Verify keyspace name spelling against DESCRIBE KEYSPACES.","Confirm schema agreement across the cluster before starting a new node."],"tags":["bootstrap","token-allocation","keyspace","configuration"],"backgroundTag":"resource-not-found","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"}