cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject [1/4] cassandra git commit: Fix sstable selection when anticompacting
Date Thu, 10 Sep 2015 12:44:47 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk c18ab3857 -> 55b6e8a07


Fix sstable selection when anticompacting

Patch by Marcus Olsson; reviewed by marcuse for CASSANDRA-10299


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/9dd84713
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/9dd84713
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/9dd84713

Branch: refs/heads/trunk
Commit: 9dd847135ffdde384b48bdb8a147b27d8bb8b6a4
Parents: acc08ae
Author: Marcus Olsson <marcus.olsson@ericsson.com>
Authored: Thu Sep 10 11:43:26 2015 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Thu Sep 10 14:32:41 2015 +0200

----------------------------------------------------------------------
 .../db/compaction/CompactionManager.java        | 28 +++++++++++++-------
 .../db/compaction/AntiCompactionTest.java       |  2 +-
 2 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9dd84713/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
index 5d88a11..e60675a 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -440,12 +440,18 @@ public class CompactionManager implements CompactionManagerMBean
         Iterator<SSTableReader> sstableIterator = sstables.iterator();
         try
         {
+            List<Range<Token>> normalizedRanges = Range.normalize(ranges);
+
             while (sstableIterator.hasNext())
             {
                 SSTableReader sstable = sstableIterator.next();
-                for (Range<Token> r : Range.normalize(ranges))
+
+                Range<Token> sstableRange = new Range<>(sstable.first.getToken(),
sstable.last.getToken(), sstable.partitioner);
+
+                boolean shouldAnticompact = false;
+
+                for (Range<Token> r : normalizedRanges)
                 {
-                    Range<Token> sstableRange = new Range<>(sstable.first.getToken(),
sstable.last.getToken(), sstable.partitioner);
                     if (r.contains(sstableRange))
                     {
                         logger.info("SSTable {} fully contained in range {}, mutating repairedAt
instead of anticompacting", sstable, r);
@@ -453,20 +459,22 @@ public class CompactionManager implements CompactionManagerMBean
                         sstable.reloadSSTableMetadata();
                         mutatedRepairStatuses.add(sstable);
                         sstableIterator.remove();
+                        shouldAnticompact = true;
                         break;
                     }
-                    else if (!sstableRange.intersects(r))
-                    {
-                        logger.info("SSTable {} ({}) does not intersect repaired range {},
not touching repairedAt.", sstable, sstableRange, r);
-                        nonAnticompacting.add(sstable);
-                        sstableIterator.remove();
-                        break;
-                    }
-                    else
+                    else if (sstableRange.intersects(r))
                     {
                         logger.info("SSTable {} ({}) will be anticompacted on range {}",
sstable, sstableRange, r);
+                        shouldAnticompact = true;
                     }
                 }
+
+                if (!shouldAnticompact)
+                {
+                    logger.info("SSTable {} ({}) does not intersect repaired ranges {}, not
touching repairedAt.", sstable, sstableRange, normalizedRanges);
+                    nonAnticompacting.add(sstable);
+                    sstableIterator.remove();
+                }
             }
             cfs.getDataTracker().notifySSTableRepairedStatusChanged(mutatedRepairStatuses);
             cfs.getDataTracker().unmarkCompacting(Sets.union(nonAnticompacting, mutatedRepairStatuses));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9dd84713/test/unit/org/apache/cassandra/db/compaction/AntiCompactionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/compaction/AntiCompactionTest.java b/test/unit/org/apache/cassandra/db/compaction/AntiCompactionTest.java
index 7756abe..56af801 100644
--- a/test/unit/org/apache/cassandra/db/compaction/AntiCompactionTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/AntiCompactionTest.java
@@ -148,7 +148,7 @@ public class AntiCompactionTest extends SchemaLoader
         ColumnFamilyStore store = prepareColumnFamilyStore();
         Collection<SSTableReader> sstables = store.getUnrepairedSSTables();
         assertEquals(store.getSSTables().size(), sstables.size());
-        Range<Token> range = new Range<Token>(new BytesToken("-10".getBytes()),
new BytesToken("-1".getBytes()));
+        Range<Token> range = new Range<Token>(new BytesToken("-1".getBytes()),
new BytesToken("-10".getBytes()));
         List<Range<Token>> ranges = Arrays.asList(range);
 
         Refs<SSTableReader> refs = Refs.tryRef(sstables);


Mime
View raw message