{"record":{"id":"659e5efc3803bde6","repo":"apache/cassandra","slug":"can-t-unregister-node-s","errorCode":null,"errorMessage":"Can't unregister node(s):\n","messagePattern":"Can't unregister node\\(s\\):\n","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tcm/CMSOperations.java","lineNumber":348,"sourceCode":"                switch (nodeState)\n                {\n                    case REGISTERED:\n                    case BOOTSTRAPPING:\n                    case BOOT_REPLACING:\n                        message.append(\" - need to use `nodetool abortbootstrap` instead of unregistering\").append('\\n');\n                        break;\n                    case JOINED:\n                        message.append(\" - use `nodetool decommission` or `nodetool removenode` to remove this node\").append('\\n');\n                        break;\n                    case MOVING:\n                        message.append(\" - wait until move has been completed, then use `nodetool decommission` or `nodetool removenode` to remove this node\").append('\\n');\n                        break;\n                    case LEAVING:\n                        message.append(\" - wait until leave-operation has completed, then retry this command\").append('\\n');\n                        break;\n                }\n            }\n            throw new IllegalStateException(\"Can't unregister node(s):\\n\" + message);\n        }\n\n        for (NodeId nodeId : nodeIds)\n        {\n            logger.info(\"Unregistering \" + nodeId);\n            cms.commit(new Unregister(nodeId, EnumSet.of(NodeState.LEFT), ClusterMetadataService.instance().placementProvider()));\n        }\n    }\n\n    public Map<Long, Map<String, String>> dumpDirectory(boolean tokens)\n    {\n        Map<Long, Map<String, Object>> directory = ClusterMetadataDirectoryTable.directory(tokens);\n        return convertToStringValues(directory);\n    }\n\n    public Map<Long, Map<String, String>> dumpLog(long startEpoch, long endEpoch)\n    {\n        Map<Long, Map<String, Object>> log = ClusterMetadataLogTable.log(startEpoch, endEpoch);","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tcm/CMSOperations.java#L330-L366","documentation":"Thrown by CMSOperations.unregisterLeftNodes when one or more nodes cannot be unregistered because their current NodeState does not permit it. The message lists each node with a state-specific remediation hint.","triggerScenarios":"Calling unregisterLeftNodes with node ids whose cluster metadata state is not LEFT (e.g. still LEAVING, decommission in progress, or in some other non-removable state).","commonSituations":"Running nodetool unregister on nodes whose decommission has not finished, batch-unregistering nodes where one is mid-leave, or retrying too soon after a failed decommission.","solutions":["Inspect the reported per-node messages: wait until the leave operation completes, then retry.","Complete or abort any in-progress decommission/leave for the blocking nodes.","Verify each node's NodeState via cluster metadata before re-running unregister."],"exampleFix":"// before\nnodetool unregister nodeA nodeB // nodeB still LEAVING\n// after\n# wait for nodeB decommission to finish, then:\nnodetool unregister nodeA nodeB","handlingStrategy":"validation","validationCode":"for (NodeId id : nodeIds) { NodeState st = ClusterMetadata.current().plan.get(id).state(); if (st != NodeState.LEFT) throw new IllegalStateException(id + \" not LEFT yet (\" + st + \"); wait for leave to complete\"); }","typeGuard":null,"tryCatchPattern":"try { ops.unregisterLeftNodes(nodeIds); } catch (IllegalStateException e) { logger.warn(\"Unregister deferred: {}\", e.getMessage()); }","preventionTips":["Wait for decommission completion before unregister","Unregister one node at a time to isolate blocking states","Read per-node remediation hints in the error message"],"tags":["tcm","node-operations","invalid-state"],"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"}