You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by sp...@apache.org on 2017/03/20 19:25:30 UTC

[02/10] cassandra git commit: Avoid anti-compacting repaired sstables

Avoid anti-compacting repaired sstables

patch by Stefan Podkowinski; reviewed by Marcus Eriksson for CASSANDRA-13153


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

Branch: refs/heads/cassandra-3.0
Commit: 06316df549c0096bd774893a405d1d32512e97bf
Parents: a69f688
Author: Stefan Podkowinski <s....@gmail.com>
Authored: Thu Feb 16 10:32:22 2017 +0100
Committer: Stefan Podkowinski <s....@gmail.com>
Committed: Mon Mar 20 19:36:57 2017 +0100

----------------------------------------------------------------------
 CHANGES.txt                                         |  1 +
 .../cassandra/db/compaction/CompactionManager.java  | 16 +++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/06316df5/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2a8330e..27dd343 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.10
+ * Don't anti-compact repaired data to avoid inconsistencies (CASSANDRA-13153)
  * Wrong logger name in AnticompactionTask (CASSANDRA-13343)
  * Fix queries updating multiple time the same list (CASSANDRA-13130)
  * Fix GRANT/REVOKE when keyspace isn't specified (CASSANDRA-13053)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/06316df5/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 8a3c11e..d21f1e8 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -1212,7 +1212,21 @@ public class CompactionManager implements CompactionManagerMBean
         logger.info("Performing anticompaction on {} sstables", repaired.originals().size());
 
         //Group SSTables
-        Collection<Collection<SSTableReader>> groupedSSTables = cfs.getCompactionStrategy().groupSSTablesForAntiCompaction(repaired.originals());
+        Set<SSTableReader> sstables = repaired.originals();
+
+        // Repairs can take place on both unrepaired (incremental + full) and repaired (full) data.
+        // Although anti-compaction could work on repaired sstables as well and would result in having more accurate
+        // repairedAt values for these, we still avoid anti-compacting already repaired sstables, as we currently don't
+        // make use of any actual repairedAt value and splitting up sstables just for that is not worth it at this point.
+        Set<SSTableReader> unrepairedSSTables = ImmutableSet.copyOf(Iterables.filter(sstables, new Predicate<SSTableReader>()
+        {
+            public boolean apply(SSTableReader input)
+            {
+                return !input.isRepaired();
+            }
+        }));
+
+        Collection<Collection<SSTableReader>> groupedSSTables = cfs.getCompactionStrategy().groupSSTablesForAntiCompaction(unrepairedSSTables);
         // iterate over sstables to check if the repaired / unrepaired ranges intersect them.
         int antiCompactedSSTableCount = 0;
         for (Collection<SSTableReader> sstableGroup : groupedSSTables)