{"record":{"id":"bc7585dd80aa356c","repo":"apache/cassandra","slug":"bad-node-state-nodestate","errorCode":null,"errorMessage":"Bad node state: {nodeState}","messagePattern":"Bad node state: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StorageService.java","lineNumber":3812,"sourceCode":"\n        NodeState nodeState = ClusterMetadata.current().myNodeState();\n        switch (nodeState)\n        {\n            case REGISTERED:\n                return Mode.STARTING;\n            case BOOT_REPLACING:\n            case BOOTSTRAPPING:\n                return Mode.JOINING;\n            case JOINED:\n                return NORMAL;\n            case LEAVING:\n                return Mode.LEAVING;\n            case LEFT:\n                return Mode.DECOMMISSIONED;\n            case MOVING:\n                return Mode.MOVING;\n        }\n        throw new IllegalStateException(\"Bad node state: \" + nodeState);\n    }\n\n    public boolean isStarting()\n    {\n        return operationMode() == Mode.STARTING;\n    }\n\n    public boolean isMoving()\n    {\n        return operationMode() == Mode.MOVING;\n    }\n\n    public boolean isJoining()\n    {\n        return operationMode() == Mode.JOINING;\n    }\n\n    public boolean isDrained()","sourceCodeStart":3794,"sourceCodeEnd":3830,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StorageService.java#L3794-L3830","documentation":"StorageService.operationMode() maps the internal node state enum to the externally visible Mode. If the internal state has no mapping (an internal invariant violation, e.g. a new enum value added without updating this switch), it throws IllegalStateException to fail fast rather than return a bogus mode. This is a defensive 'should never happen' guard, not a user-caused condition.","triggerScenarios":"Calling operationMode() (directly or via isStarting()/jmx getOperationMode) when the node's internal state enum value is not handled by the switch in getOperationMode().","commonSituations":"Custom patches or forks adding new node states; running a partially upgraded/mixed-version cluster where a newer state value is seen; corrupted in-memory state during startup races.","solutions":["Restart the node; transient uninitialize states usually clear","Upgrade Cassandra to a version where all node states are mapped","Check for patched/modified code that added a new node state enum value without updating the mapping switch","Report a bug with full node logs - this indicates an internal invariant violation"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"String mode = storageService.getOperationMode(); // inspect instead of assuming\nif (mode == null || mode.isEmpty()) { /* node in unexpected state */ }","typeGuard":null,"tryCatchPattern":"try { operationMode(); } catch (IllegalStateException e) { log.error(\"node state enum unmapped - upgrade/patch bug\", e); restartNode(); }","preventionTips":["Run unmodified, released Cassandra binaries","Keep cluster versions consistent during rolling upgrades","Treat this error as a bug report, not an operator error"],"tags":["internal-error","node-state","invariant"],"backgroundTag":"internal-invariant-violation","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"}