diff --git a/src/java/org/apache/cassandra/repair/RepairCoordinator.java b/src/java/org/apache/cassandra/repair/RepairCoordinator.java index 8aa3482b5e06..99bce6a1934d 100644 --- a/src/java/org/apache/cassandra/repair/RepairCoordinator.java +++ b/src/java/org/apache/cassandra/repair/RepairCoordinator.java @@ -407,9 +407,15 @@ private NeighborsAndRanges getNeighborsAndRanges() throws RepairException EndpointsForRange allForRange = ctx.repair().getNeighbors(state.keyspace, keyspaceLocalRanges, range); allNeighbors.addAll(allForRange.endpoints()); + Collection specificHosts = Sets.newHashSet(state.options.getHosts()); + if (isCMS && isMeta && !specificHosts.isEmpty()) + { + logger.info("{} Repair requested with specific hosts {} for {} - repairing the full CMS instead", state.id, specificHosts, state.keyspace); + specificHosts.clear(); + } EndpointsForRange includeForRange = ctx.repair().filterNeighbors(allForRange, range, state.options.getDataCenters(), - state.options.getHosts()); + specificHosts); if (includeForRange.isEmpty()) { diff --git a/test/distributed/org/apache/cassandra/distributed/test/log/RepairSystemClusterMetadataTest.java b/test/distributed/org/apache/cassandra/distributed/test/log/RepairSystemClusterMetadataTest.java index 178be004fa5c..0e5d31ca4fac 100644 --- a/test/distributed/org/apache/cassandra/distributed/test/log/RepairSystemClusterMetadataTest.java +++ b/test/distributed/org/apache/cassandra/distributed/test/log/RepairSystemClusterMetadataTest.java @@ -19,6 +19,7 @@ package org.apache.cassandra.distributed.test.log; import java.io.IOException; +import java.util.concurrent.ExecutionException; import org.junit.Test; @@ -38,4 +39,16 @@ public void testGlobalRepair() throws IOException cluster.get(4).nodetoolResult("repair", "-force", "-st", "-1", "-et", "3074457345618258601", "system_cluster_metadata").asserts().success(); } } + + @Test + public void testHostTargetedRepair() throws IOException, ExecutionException, InterruptedException + { + try (Cluster cluster = init(builder().withNodes(6).withConfig(c -> c.with(Feature.NETWORK, Feature.GOSSIP)) + .start())) + { + cluster.get(1).nodetoolResult("cms", "reconfigure", "3").asserts().success(); + cluster.get(2).shutdown().get(); + cluster.get(3).nodetoolResult("repair", "-force", "-hosts", "127.0.0.3", "-hosts", "127.0.0.4", "system_cluster_metadata").asserts().success(); + } + } }