Enable repair -pr and -local together (fix regression of CASSANDRA-7450)

Patch by Jérôme Mainaud; Reviewed by Paulo Motta for CASSANDRA-12522
This commit is contained in:
Jérôme Mainaud 2016-08-26 20:51:40 -03:00 committed by Aleksey Yeschenko
parent acd46ab7c4
commit 6eff0829d2
4 changed files with 27 additions and 2 deletions

View File

@ -1,4 +1,5 @@
2.2.8
* Enable repair -pr and -local together (fix regression of CASSANDRA-7450) (CASSANDRA-12522)
* Fail repair on non-existing table (CASSANDRA-12279)
* cqlsh copy: fix missing counter values (CASSANDRA-12476)
* Move migration tasks to non-periodic queue, assure flush executor shutdown after non-periodic executor (CASSANDRA-12251)

View File

@ -208,7 +208,7 @@ public class RepairOption
{
throw new IllegalArgumentException("Too many job threads. Max is " + MAX_JOB_THREADS);
}
if (primaryRange && (!dataCenters.isEmpty() || !hosts.isEmpty()))
if (primaryRange && ((!dataCenters.isEmpty() && !option.isInLocalDCOnly()) || !hosts.isEmpty()))
{
throw new IllegalArgumentException("You need to run primary range repair on all nodes in the cluster.");
}
@ -303,6 +303,10 @@ public class RepairOption
return isSubrangeRepair;
}
public boolean isInLocalDCOnly() {
return dataCenters.size() == 1 && dataCenters.contains(DatabaseDescriptor.getLocalDataCenter());
}
@Override
public String toString()
{

View File

@ -2801,7 +2801,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
if (option.getDataCenters().isEmpty() && option.getHosts().isEmpty())
option.getRanges().addAll(getPrimaryRanges(keyspace));
// except dataCenters only contain local DC (i.e. -local)
else if (option.getDataCenters().size() == 1 && option.getDataCenters().contains(DatabaseDescriptor.getLocalDataCenter()))
else if (option.isInLocalDCOnly())
option.getRanges().addAll(getPrimaryRangesWithinDC(keyspace));
else
throw new IllegalArgumentException("You need to run primary range repair on all nodes in the cluster.");

View File

@ -96,6 +96,26 @@ public class RepairOptionTest
assertEquals(expectedHosts, option.getHosts());
}
@Test
public void testPrWithLocalParseOptions()
{
DatabaseDescriptor.forceStaticInitialization();
Map<String, String> options = new HashMap<>();
options.put(RepairOption.PARALLELISM_KEY, "parallel");
options.put(RepairOption.PRIMARY_RANGE_KEY, "true");
options.put(RepairOption.INCREMENTAL_KEY, "false");
options.put(RepairOption.COLUMNFAMILIES_KEY, "cf1,cf2,cf3");
options.put(RepairOption.DATACENTERS_KEY, "datacenter1");
RepairOption option = RepairOption.parse(options, Murmur3Partitioner.instance);
assertTrue(option.isPrimaryRange());
Set<String> expectedDCs = new HashSet<>(3);
expectedDCs.add("datacenter1");
assertEquals(expectedDCs, option.getDataCenters());
}
@Test
public void testIncrementalRepairWithSubrangesIsNotGlobal() throws Exception
{