{"record":{"id":"dad6ec3433ec2ccc","repo":"apache/cassandra","slug":"allocated-token-s-already-assigned-to-node-s-is","errorCode":null,"errorMessage":"Allocated token %s already assigned to node %s. Is another node also allocating tokens?","messagePattern":"Allocated token (.+?) already assigned to node (.+?)\\. Is another node also allocating tokens\\?","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/dht/tokenallocator/TokenAllocation.java","lineNumber":187,"sourceCode":"                InetAddressAndPort endpoint = metadata.directory.endpoint(en.getValue());\n                if (inAllocationRing(metadata.locator, endpoint))\n                    sortedTokens.put(en.getKey(), endpoint);\n            }\n            return TokenAllocatorFactory.createTokenAllocator(sortedTokens, this, metadata.tokenMap.partitioner());\n        }\n\n        final Collection<Token> adjustForCrossDatacenterClashes(Collection<Token> tokens)\n        {\n            List<Token> filtered = Lists.newArrayListWithCapacity(tokens.size());\n\n            for (Token t : tokens)\n            {\n                while (metadata.tokenMap.owner(t) != null)\n                {\n                    NodeId nodeId = metadata.tokenMap.owner(t);\n                    InetAddressAndPort other = metadata.directory.endpoint(nodeId);\n                    if (inAllocationRing(metadata.locator, other))\n                        throw new ConfigurationException(String.format(\"Allocated token %s already assigned to node %s. Is another node also allocating tokens?\", t, other));\n                    t = t.nextValidToken();\n                }\n                filtered.add(t);\n            }\n            return filtered;\n        }\n\n        final SummaryStatistics replicatedOwnershipStats()\n        {\n            SummaryStatistics stat = new SummaryStatistics();\n            for (Map.Entry<InetAddressAndPort, Double> en : evaluateReplicatedOwnership().entrySet())\n            {\n                // Filter only in the same allocation ring\n                if (inAllocationRing(metadata.locator, en.getKey()))\n                {\n                    NodeId nodeId = metadata.directory.peerId(en.getKey());\n                    stat.addValue(en.getValue() / metadata.tokenMap.tokens(nodeId).size());\n                }","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/dht/tokenallocator/TokenAllocation.java#L169-L205","documentation":"TokenAllocation throws ConfigurationException when a token chosen by the allocator is already owned by another node in the same allocation ring (same datacenter/rack scope). It indicates two nodes are allocating tokens concurrently or a racing allocation has claimed the same token.","triggerScenarios":"Calling allocate when, during adjustForCrossDatacenterClashes, metadata.tokenMap.owner(token) returns a non-null node that is inAllocationRing — i.e. the token is taken by another node in the same DC.","commonSituations":"Two or more nodes bootstrapping simultaneously with token allocation enabled; a node bootstrapping while another allocation just finished; clustered automated provisioning racing across nodes.","solutions":["Retry the node bootstrap after the other allocation completes (serialize node joins)","Ensure only one node allocates tokens at a time — use deterministic ordering in provisioning scripts","Check nodetool ring for the conflicting token owner and choose a different token/bootstrap order","If metadata is stale, wait for gossip convergence and retry"],"exampleFix":"// before: two nodes bootstrap in parallel\nansible all -m cassandra_bootstrap  # race -> ConfigurationException\n// after: join nodes sequentially\n- hosts: cassandra[0]\n  tasks: [bootstrap node]\n- hosts: cassandra[1]\n  tasks: [bootstrap next node after previous is Up/Normal]","handlingStrategy":"retry","validationCode":"// before bootstrapping a new node, confirm no other node is currently bootstrapping\nnodetool status  # no 'UJ' (Up/Joining) nodes\n// and confirm the candidate tokens are unowned in nodetool ring","typeGuard":null,"tryCatchPattern":"try {\n    TokenAllocation.allocate(metadata, ks, dc);\n} catch (ConfigurationException e) {\n    if (e.getMessage().contains(\"already assigned\")) {\n        // backoff and retry once other node finished joining\n    }\n}","preventionTips":["Bootstrap nodes sequentially, not in parallel","Use provisioning tooling that serializes token allocation","Wait for previous bootstrap to reach Up/Normal before starting next","Monitor for UJ state in nodetool status"],"tags":["token-allocation","topology","concurrency"],"backgroundTag":"token-assignment-conflict","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}