{"record":{"id":"189c35e36474b506","repo":"apache/cassandra","slug":"tried-to-replace-same-address-but-node-does-not-s","errorCode":null,"errorMessage":"Tried to replace same address, but node does not seem to be registered","messagePattern":"Tried to replace same address, but node does not seem to be registered","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tcm/transformations/Register.java","lineNumber":113,"sourceCode":"        for (Map.Entry<NodeId, NodeAddresses> entry : prev.directory.addresses.entrySet())\n        {\n            NodeAddresses existingAddresses = entry.getValue();\n            if (addresses.conflictsWith(existingAddresses))\n                return new Rejected(INVALID, String.format(\"New addresses %s conflicts with existing node %s with addresses %s\", addresses, entry.getKey(), existingAddresses));\n        }\n\n        ClusterMetadata.Transformer next = prev.transformer()\n                                               .register(addresses, location, version);\n        return Transformation.success(next, LockedRanges.AffectedRanges.EMPTY);\n    }\n\n    public static NodeId maybeRegister()\n    {\n        if (isReplacingSameAddress())\n        {\n            NodeId self = ClusterMetadata.current().myNodeId();\n            if (self == NodeId.UNREGISTERED)\n                throw new IllegalStateException(\"Tried to replace same address, but node does not seem to be registered\");\n\n            return self;\n        }\n        return register(false);\n    }\n\n    @VisibleForTesting\n    public static NodeId register(NodeAddresses nodeAddresses)\n    {\n        return register(nodeAddresses, NodeVersion.CURRENT);\n    }\n\n    @VisibleForTesting\n    public static NodeId register(NodeAddresses nodeAddresses, Location location)\n    {\n        return register(nodeAddresses, location, NodeVersion.CURRENT);\n    }\n","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tcm/transformations/Register.java#L95-L131","documentation":"Thrown by ClusterMetadataService.maybeRegister() when the node is configured to replace an existing node at the same broadcast address (cassandra.replace_address pointing at itself), but this node has no NodeId in the current cluster metadata directory. Registration exists to hand out a NodeId; replacement requires the node to already be a registered member whose identity can be reused.","triggerScenarios":"Calling maybeRegister() when isReplacingSameAddress() is true and ClusterMetadata.current().myNodeId() returns NodeId.UNREGISTERED — i.e. the local node is not present in the CMS directory under the current address.","commonSituations":"Starting a node with cassandra.replace_address equal to its own address after the old node was fully removed (unregistered) from cluster metadata; stale data dirs left behind while metadata was reset; attempting replacement before the node ever joined.","solutions":["Remove cassandra.replace_address (the address is free; do a normal bootstrap/register instead)","If replacement is intended, ensure the old node is still registered in CMS (verify with nodetool status / cms show); re-register it or restore cluster metadata","Wipe stale system.local host id and data directories, then start as a fresh node"],"exampleFix":"// before: cassandra.yaml\nauto_bootstrap: true\nreplace_address: 10.0.0.5  // same as this node, already unregistered\n// after\nauto_bootstrap: true\n// remove replace_address and let the node register normally","handlingStrategy":"validation","validationCode":"// before starting with replacement\nNodeId self = ClusterMetadata.current().myNodeId();\nif (isReplacingSameAddress() && self == NodeId.UNREGISTERED) {\n    // the node is not registered; do a normal register instead of replace\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only set replace_address when the target node is still registered in cluster metadata","Use replace_node with an explicit host id instead of replace_address self-replacement","Wipe data dirs when the old node was already removed from CMS"],"tags":["cluster-membership","bootstrap","node-replacement"],"backgroundTag":"invalid-state-transition","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"}