diff --git a/CHANGES.txt b/CHANGES.txt index 0e4ade3084..d4cc15f81a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.0.17 + * Disallow decommission when node is in drained state (CASSANDRA-8741) * Backport CASSANDRA-8013 to 2.0 (CASSANDRA-10144) * Make getFullyExpiredSSTables less expensive (CASSANDRA-9882) * Add tool to find why expired sstables are not getting dropped (CASSANDRA-10015) diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index 745fe4c922..5ac49802d3 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -2963,6 +2963,8 @@ public class StorageService extends NotificationBroadcasterSupport implements IE throw new UnsupportedOperationException("local node is not a member of the token ring yet"); if (tokenMetadata.cloneAfterAllLeft().sortedTokens().size() < 2) throw new UnsupportedOperationException("no other normal nodes in the ring; decommission would be pointless"); + if (operationMode != Mode.NORMAL) + throw new UnsupportedOperationException("Node in " + operationMode + " state; wait for status to become normal or restart"); PendingRangeCalculatorService.instance.blockUntilFinished(); for (String keyspaceName : Schema.instance.getNonSystemKeyspaces()) diff --git a/src/java/org/apache/cassandra/tools/NodeCmd.java b/src/java/org/apache/cassandra/tools/NodeCmd.java index b006d694c6..80710131be 100644 --- a/src/java/org/apache/cassandra/tools/NodeCmd.java +++ b/src/java/org/apache/cassandra/tools/NodeCmd.java @@ -1366,7 +1366,8 @@ public class NodeCmd System.err.println("Decommission will decommission the node you are connected to and does not take arguments!"); System.exit(1); } - probe.decommission(); + try { probe.decommission(); } + catch (UnsupportedOperationException e) { err("Unsupported operation: " + e.getMessage()); } break; case DRAIN : @@ -1678,6 +1679,12 @@ public class NodeCmd System.exit(1); } + private static void err(String useStr) + { + System.err.println(useStr); + System.exit(1); + } + private static void err(Exception e, String errStr) { System.err.println(errStr);