Repository: cassandra Updated Branches: refs/heads/cassandra-2.1 f67b7a477 -> 84626372c refs/heads/trunk 937189237 -> 8c1e4e089
Fix potentially repairing with wrong nodes patch by yukim; reviewed by krummas for CASSANDRA-6808 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/84626372 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/84626372 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/84626372 Branch: refs/heads/cassandra-2.1 Commit: 84626372c0ae007bb55e0072d981d856f5a8e72c Parents: f67b7a4 Author: Yuki Morishita <yu...@apache.org> Authored: Thu Mar 6 15:24:52 2014 -0600 Committer: Yuki Morishita <yu...@apache.org> Committed: Thu Mar 6 15:24:52 2014 -0600 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../org/apache/cassandra/service/StorageService.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/84626372/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index af7f2fd..df19467 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,7 @@ * Scrub should not always clear out repaired status (CASSANDRA-5351) * Improve handling of range tombstone for wide partitions (CASSANDRA-6446) * Fix ClassCastException for compact table with composites (CASSANDRA-6738) + * Fix potentially repairing with wrong nodes (CASSANDRA-6808) Merged from 2.0: * Avoid race-prone second "scrub" of system keyspace (CASSANDRA-6797) * Pool CqlRecordWriter clients by inetaddress rather than Range http://git-wip-us.apache.org/repos/asf/cassandra/blob/84626372/src/java/org/apache/cassandra/service/StorageService.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java index e358f7d..132e674 100644 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@ -2577,9 +2577,14 @@ public class StorageService extends NotificationBroadcasterSupport implements IE return; } - Set<InetAddress> neighbours = new HashSet<>(); + Set<InetAddress> allNeighbors = new HashSet<>(); + Map<Range, Set<InetAddress>> rangeToNeighbors = new HashMap<>(); for (Range<Token> range : ranges) - neighbours.addAll(ActiveRepairService.getNeighbors(keyspace, range, dataCenters, hosts)); + { + Set<InetAddress> neighbors = ActiveRepairService.getNeighbors(keyspace, range, dataCenters, hosts); + rangeToNeighbors.put(range, neighbors); + allNeighbors.addAll(neighbors); + } List<ColumnFamilyStore> columnFamilyStores = new ArrayList<>(); for (ColumnFamilyStore cfs : getValidColumnFamilies(false, false, keyspace, columnFamilies)) @@ -2587,7 +2592,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE UUID parentSession = null; if (!fullRepair) - parentSession = ActiveRepairService.instance.prepareForRepair(neighbours, ranges, columnFamilyStores); + parentSession = ActiveRepairService.instance.prepareForRepair(allNeighbors, ranges, columnFamilyStores); List<RepairFuture> futures = new ArrayList<>(ranges.size()); for (Range<Token> range : ranges) @@ -2595,7 +2600,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE RepairFuture future; try { - future = forceKeyspaceRepair(parentSession, range, keyspace, isSequential, neighbours, columnFamilies); + future = forceKeyspaceRepair(parentSession, range, keyspace, isSequential, rangeToNeighbors.get(range), columnFamilies); } catch (IllegalArgumentException e) { @@ -2642,7 +2647,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE } } if (!fullRepair) - ActiveRepairService.instance.finishParentSession(parentSession, neighbours); + ActiveRepairService.instance.finishParentSession(parentSession, allNeighbors); sendNotification("repair", String.format("Repair command #%d finished", cmd), new int[]{cmd, ActiveRepairService.Status.FINISHED.ordinal()}); } }, null);