{"record":{"id":"82908091d059ce63","repo":"apache/cassandra","slug":"target-token-s-is-already-owned-by-another-node","errorCode":null,"errorMessage":"target token %s is already owned by another node.","messagePattern":"target token (.+?) is already owned by another node\\.","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tcm/sequences/SingleNodeSequences.java","lineNumber":178,"sourceCode":"    {\n        abortHelper(nodeId, MultiStepOperation.Kind.REMOVE, null);\n    }\n\n    /**\n     * move the node to new token or find a new token to boot to according to load\n     *\n     * @param newToken new token to boot to, or if null, find balanced token to boot to\n     */\n    static void move(Token newToken)\n    {\n        if (ClusterMetadataService.instance().isMigrating() || ClusterMetadataService.state() == ClusterMetadataService.State.GOSSIP)\n            throw new IllegalStateException(\"This cluster is migrating to cluster metadata, can't move until that is done.\");\n\n        if (newToken == null)\n            throw new IllegalArgumentException(\"Can't move to the undefined (null) token.\");\n\n        if (ClusterMetadata.current().tokenMap.tokens().contains(newToken))\n            throw new IllegalArgumentException(String.format(\"target token %s is already owned by another node.\", newToken));\n\n        // address of the current node\n        ClusterMetadata metadata = ClusterMetadata.current();\n        NodeId self = metadata.myNodeId();\n        // This doesn't make any sense in a vnodes environment.\n        if (metadata.tokenMap.tokens(self).size() > 1)\n        {\n            logger.error(\"Invalid request to move(Token); This node has more than one token and cannot be moved thusly.\");\n            throw new UnsupportedOperationException(\"This node has more than one token and cannot be moved thusly.\");\n        }\n\n        ClusterMetadataService.instance().commit(new PrepareMove(self,\n                                                                 Collections.singleton(newToken),\n                                                                 ClusterMetadataService.instance().placementProvider(),\n                                                                 true),\n                                                 m -> m,\n                                                 failureHandler(\"PrepareMove\", StorageService.instance::markMoveFailed));\n        InProgressSequences.finishInProgressSequences(self);","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tcm/sequences/SingleNodeSequences.java#L160-L196","documentation":"move checks ClusterMetadata.current().tokenMap.tokens() and throws IllegalArgumentException if the requested target token is already assigned to some node in the ring. Tokens must be unique; moving onto an owned token would corrupt ownership ranges.","triggerScenarios":"Running `nodetool move <token>` with a token that already exists in the ring - e.g. copying another node's token, reusing a token from a removed node that is still registered, or computing a token that collides with an existing one.","commonSituations":"Rebalancing scripts that hardcode tokens from a stale ring snapshot; attempting to move a node onto the token of a node removed earlier but still present in cluster metadata; initial_token reuse across nodes.","solutions":["Choose a token not present in the ring: run `nodetool ring` (or query ClusterMetadata.tokenMap) and pick an unowned token.","If the token belongs to a stale/removed node, finish removing that node first (removenode), then retry.","Use a load-balancing tool or omit the explicit token so a balanced unowned token is chosen automatically."],"exampleFix":"// before\nss.move(existingToken); // IllegalArgumentException\n// after\nSet<Token> owned = ClusterMetadata.current().tokenMap.tokens();\nif (!owned.contains(newToken)) ss.move(newToken);","handlingStrategy":"validation","validationCode":"if (ClusterMetadata.current().tokenMap.tokens().contains(newToken))\n    throw new IllegalArgumentException(\"token already owned: \" + newToken);","typeGuard":null,"tryCatchPattern":"try { move(token); }\ncatch (IllegalArgumentException e) { if (e.getMessage().contains(\"already owned\")) { pickUnownedToken(); } else throw e; }","preventionTips":["Refresh the ring view immediately before choosing a token","Never hardcode tokens from stale snapshots","Ensure removed nodes are fully removed before reusing their tokens"],"tags":["cassandra","token-ownership","topology","duplicate-value"],"backgroundTag":"invalid-argument-value","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"}