cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: Fix memtable flushing for indexed tables
Date Sun, 29 Sep 2013 23:18:43 GMT
Updated Branches:
  refs/heads/cassandra-2.0 65773b1cd -> dc7e2fdd9


Fix memtable flushing for indexed tables

patch by Aleksey Yeschenko; reviewed by Jonathan Ellis for
CASSANDRA-6112


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

Branch: refs/heads/cassandra-2.0
Commit: dc7e2fdd9d57d3e7fed58ea9dbbfb0684c8383d9
Parents: 65773b1
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Mon Sep 30 02:17:51 2013 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Mon Sep 30 02:17:51 2013 +0300

----------------------------------------------------------------------
 CHANGES.txt                                                  | 1 +
 src/java/org/apache/cassandra/db/Memtable.java               | 6 +++++-
 .../apache/cassandra/db/compaction/CompactionManager.java    | 4 ++--
 .../org/apache/cassandra/db/index/SecondaryIndexManager.java | 8 ++++++++
 4 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/dc7e2fdd/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 061ad12..dcdb01b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -10,6 +10,7 @@
    leveled manifest (CASSANDRA-6093)
  * make sequential nodetool repair the default (CASSANDRA-5950)
  * Add more hooks for compaction strategy implementations (CASSANDRA-6111)
+ * Fix memtable flushing for indexed tables (CASSANDRA-6112)
 Merged from 1.2:
  * Allow estimated memtable size to exceed slab allocator size (CASSANDRA-6078)
  * Start MeteredFlusher earlier to prevent OOM during CL replay (CASSANDRA-6087)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/dc7e2fdd/src/java/org/apache/cassandra/db/Memtable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java
index 14ce74c..f1bb1a5 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -351,7 +351,11 @@ public class Memtable
                         // But it can result in unexpected behaviour where deletes never
make it to disk,
                         // as they are lost and so cannot override existing column values.
So we only remove deleted columns if there
                         // is a CF level tombstone to ensure the delete makes it into an
SSTable.
-                        ColumnFamilyStore.removeDeletedColumnsOnly(cf, Integer.MIN_VALUE);
+                        // We also shouldn't be dropping any columns obsoleted by partition
and/or range tombstones in case
+                        // the table has secondary indexes, or else the stale entries wouldn't
be cleaned up during compaction,
+                        // and will only be dropped during 2i query read-repair, if at all.
+                        if (!cfs.indexManager.hasIndexes())
+                            ColumnFamilyStore.removeDeletedColumnsOnly(cf, Integer.MIN_VALUE);
                     }
                     writer.append((DecoratedKey)entry.getKey(), cf);
                 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/dc7e2fdd/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 f3c2011..317014f 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -525,7 +525,7 @@ public class CompactionManager implements CompactionManagerMBean
             return;
         }
 
-        boolean hasIndexes = !cfs.indexManager.getIndexes().isEmpty();
+        boolean hasIndexes = cfs.indexManager.hasIndexes();
         CleanupStrategy cleanupStrategy = CleanupStrategy.get(cfs, ranges, renewer);
 
         for (SSTableReader sstable : sstables)
@@ -623,7 +623,7 @@ public class CompactionManager implements CompactionManagerMBean
     {
         public static CleanupStrategy get(ColumnFamilyStore cfs, Collection<Range<Token>>
ranges, CounterId.OneShotRenewer renewer)
         {
-            if (!cfs.indexManager.getIndexes().isEmpty() || cfs.metadata.getDefaultValidator().isCommutative())
+            if (cfs.indexManager.hasIndexes() || cfs.metadata.getDefaultValidator().isCommutative())
                 return new Full(cfs, ranges, renewer);
 
             return new Bounded(cfs, ranges);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/dc7e2fdd/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
index eff9537..1838c03 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
@@ -377,6 +377,14 @@ public class SecondaryIndexManager
     }
 
     /**
+     * @return if there are ANY indexes for this table..
+     */
+    public boolean hasIndexes()
+    {
+        return !indexesByColumn.isEmpty();
+    }
+
+    /**
      * @return total current ram size of all indexes
      */
     public long getTotalLiveSize()


Mime
View raw message