cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/2] git commit: Fix periodic memtable flushing behavior with clean memtables
Date Fri, 23 Aug 2013 23:17:54 GMT
Updated Branches:
  refs/heads/cassandra-2.0 56008de45 -> 78d78cf64


Fix periodic memtable flushing behavior with clean memtables

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


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

Branch: refs/heads/cassandra-2.0
Commit: b0280cb92d6d0ee5e89d54d2277ba846172de61e
Parents: af9c707
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Sat Aug 24 02:15:32 2013 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Sat Aug 24 02:16:29 2013 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/db/ColumnFamilyStore.java  | 22 ++++++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b0280cb9/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 16c6e58..b68e442 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,6 @@
 2.0.0
  * Fix thrift validation when inserting into CQL3 tables (CASSANDRA-5138)
+ * Fix periodic memtable flushing behavior with clean memtables (CASSANDRA-5931)
 Merged from 1.2:
  * Fix getBloomFilterDiskSpaceUsed for AlwaysPresentFilter (CASSANDRA-5900)
  * Don't announce schema version until we've loaded the changes locally

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b0280cb9/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index b6e2f3c..f3acf4d 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -166,11 +166,12 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
                 {
                     if (getMemtableThreadSafe().isExpired())
                     {
-                        Future<?> future = forceFlush();
                         // if memtable is already expired but didn't flush because it's empty,
                         // then schedule another flush.
-                        if (future == null)
+                        if (isClean())
                             scheduleFlush();
+                        else
+                            forceFlush(); // scheduleFlush() will be called by the constructor
of the new memtable.
                     }
                 }
             };
@@ -777,15 +778,24 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         }
     }
 
-    public Future<?> forceFlush()
+    private boolean isClean()
     {
         // during index build, 2ary index memtables can be dirty even if parent is not. 
if so,
         // we want flushLargestMemtables to flush the 2ary index ones too.
-        boolean clean = true;
         for (ColumnFamilyStore cfs : concatWithIndexes())
-            clean &= cfs.getMemtableThreadSafe().isClean();
+            if (!cfs.getMemtableThreadSafe().isClean())
+                return false;
+
+        return true;
+    }
 
-        if (clean)
+    /**
+     * @return a future, with a guarantee that any data inserted prior to the forceFlush()
call is fully flushed
+     *         by the time future.get() returns. Never returns null.
+     */
+    public Future<?> forceFlush()
+    {
+        if (isClean())
         {
             // We could have a memtable for this column family that is being
             // flushed. Make sure the future returned wait for that so callers can


Mime
View raw message