You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2009/05/07 17:30:53 UTC

svn commit: r772680 - /incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java

Author: jbellis
Date: Thu May  7 15:30:53 2009
New Revision: 772680

URL: http://svn.apache.org/viewvc?rev=772680&view=rev
Log:
use explicit dirty flag instead of trying to cheat and use executor taskcount, which is race-prone.  patch by jbellis; reviewed by Eric Evans for CASSANDRA-134

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java?rev=772680&r1=772679&r2=772680&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java Thu May  7 15:30:53 2009
@@ -57,6 +57,7 @@
 
     private MemtableThreadPoolExecutor executor_;
     private volatile boolean isFrozen_;
+    private volatile boolean isDirty_;
     private volatile boolean isFlushed_; // for tests, in particular forceBlockingFlush asserts this
 
     private int threshold_ = DatabaseDescriptor.getMemtableSize()*1024*1024;
@@ -195,6 +196,7 @@
     */
     void put(String key, ColumnFamily columnFamily, CommitLog.CommitLogContext cLogCtx) throws IOException
     {
+        isDirty_ = true;
         executor_.submit(new Putter(key, columnFamily));
         if (isThresholdViolated())
         {
@@ -411,6 +413,8 @@
 
     public boolean isClean()
     {
-        return columnFamilies_.isEmpty() && executor_.getPendingTasks() == 0;
+        // executor taskcount is inadequate for our needs here -- it can return zero under certain
+        // race conditions even though a task has been processed.
+        return !isDirty_;
     }
 }