diff --git a/CHANGES.txt b/CHANGES.txt index e307843599..58c62778cf 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,7 @@ * Cleanup and optimize collation and slice iterators (CASSANDRA-7107) * Upgrade NBHM lib (CASSANDRA-7128) * Optimize netty server (CASSANDRA-6861) + * Fix repair hang when given CF does not exist (CASSANDRA-7189) Merged from 2.0: * Correctly delete scheduled range xfers (CASSANDRA-7143) * Make batchlog replica selection rack-aware (CASSANDRA-6551) diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index f1e853a04b..68257bba64 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -2444,6 +2444,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE * @param autoAddIndexes Automatically add secondary indexes if a CF has them * @param keyspaceName keyspace * @param cfNames CFs + * @throws java.lang.IllegalArgumentException when given CF name does not exist */ public Iterable getValidColumnFamilies(boolean allowIndexes, boolean autoAddIndexes, String keyspaceName, String... cfNames) throws IOException { @@ -2490,12 +2491,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE } ColumnFamilyStore cfStore = keyspace.getColumnFamilyStore(baseCfName); - if (cfStore == null) - { - // this means there was a cf passed in that is not recognized in the keyspace. report it and continue. - logger.warn(String.format("Invalid column family specified: %s. Proceeding with others.", baseCfName)); - continue; - } if (idxName != null) { Collection< SecondaryIndex > indexes = cfStore.indexManager.getIndexesByNames(new HashSet<>(Arrays.asList(cfName))); @@ -2673,14 +2668,22 @@ public class StorageService extends NotificationBroadcasterSupport implements IE catch (IllegalArgumentException e) { logger.error("Repair failed:", e); - sendNotification("repair", message, new int[]{cmd, ActiveRepairService.Status.FINISHED.ordinal()}); + sendNotification("repair", e.getMessage(), new int[]{cmd, ActiveRepairService.Status.FINISHED.ordinal()}); return; } } + // Validate columnfamilies List columnFamilyStores = new ArrayList<>(); - for (ColumnFamilyStore cfs : getValidColumnFamilies(false, false, keyspace, columnFamilies)) - columnFamilyStores.add(cfs); + try + { + Iterables.addAll(columnFamilyStores, getValidColumnFamilies(false, false, keyspace, columnFamilies)); + } + catch (IllegalArgumentException e) + { + sendNotification("repair", e.getMessage(), new int[]{cmd, ActiveRepairService.Status.FINISHED.ordinal()}); + return; + } UUID parentSession = null; if (!fullRepair) @@ -2699,7 +2702,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE List futures = new ArrayList<>(ranges.size()); for (Range range : ranges) { - RepairFuture future = forceKeyspaceRepair(parentSession, range, keyspace, isSequential, rangeToNeighbors.get(range), columnFamilies); + RepairFuture future = ActiveRepairService.instance.submitRepairSession(parentSession, range, keyspace, isSequential, rangeToNeighbors.get(range), columnFamilies); if (future == null) continue; futures.add(future); @@ -2745,29 +2748,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE }, null); } - - public RepairFuture forceKeyspaceRepair(UUID parentRepairSession, - Range range, - String keyspaceName, - boolean isSequential, - Set endpoints, - String ... columnFamilies) throws IOException - { - ArrayList names = new ArrayList<>(); - for (ColumnFamilyStore cfStore : getValidColumnFamilies(false, false, keyspaceName, columnFamilies)) - { - names.add(cfStore.name); - } - - if (names.isEmpty()) - { - logger.info("No column family to repair for keyspace {}", keyspaceName); - return null; - } - - return ActiveRepairService.instance.submitRepairSession(parentRepairSession, range, keyspaceName, isSequential, endpoints, names.toArray(new String[names.size()])); - } - public void forceTerminateAllRepairSessions() { ActiveRepairService.instance.terminateSessions(); }