cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1081929 - in /cassandra/branches/cassandra-0.7: CHANGES.txt src/java/org/apache/cassandra/db/ColumnFamilyStore.java src/java/org/apache/cassandra/db/Memtable.java
Date Tue, 15 Mar 2011 20:27:29 GMT
Author: jbellis
Date: Tue Mar 15 20:27:29 2011
New Revision: 1081929

URL: http://svn.apache.org/viewvc?rev=1081929&view=rev
Log:
reduce contention on Table.flusherLock
patch by Stu Hood and jbellis; reviewed by slebresne for CASSANDRA-1954

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1081929&r1=1081928&r2=1081929&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Tue Mar 15 20:27:29 2011
@@ -7,6 +7,7 @@
  * allow job configuration to set the CL used in Hadoop jobs (CASSANDRA-2331)
  * queue secondary indexes for flush before the parent (CASSANDRA-2330)
  * shut down server for OOM on a Thrift thread (CASSANDRA-2269)
+ * reduce contention on Table.flusherLock (CASSANDRA-1954)
 
 
 0.7.4

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1081929&r1=1081928&r2=1081929&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
Tue Mar 15 20:27:29 2011
@@ -678,6 +678,12 @@ public class ColumnFamilyStore implement
     /** flush the given memtable and swap in a new one for its CFS, if it hasn't been frozen
already.  threadsafe. */
     Future<?> maybeSwitchMemtable(Memtable oldMemtable, final boolean writeCommitLog)
     {
+        if (oldMemtable.isFrozen())
+        {
+            logger.debug("memtable is already frozen; another thread must be flushing it");
+            return null;
+        }
+
         /*
          * If we can get the writelock, that means no new updates can come in and
          * all ongoing updates to memtables have completed. We can get the tail
@@ -729,6 +735,10 @@ public class ColumnFamilyStore implement
             if (!icc.contains(this))
                 memtable = new Memtable(this);
 
+            if (memtableSwitchCount == Integer.MAX_VALUE)
+                memtableSwitchCount = 0;
+            memtableSwitchCount++;
+
             // when all the memtables have been written, including for indexes, mark the
flush in the commitlog header.
             // a second executor makes sure the onMemtableFlushes get called in the right
order,
             // while keeping the wait-for-flush (future.get) out of anything latency-sensitive.
@@ -749,11 +759,6 @@ public class ColumnFamilyStore implement
         finally
         {
             Table.flusherLock.writeLock().unlock();
-            if (memtableSwitchCount == Integer.MAX_VALUE)
-            {
-                memtableSwitchCount = 0;
-            }
-            memtableSwitchCount++;
         }
     }
 

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java?rev=1081929&r1=1081928&r2=1081929&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/Memtable.java Tue Mar
15 20:27:29 2011
@@ -52,7 +52,7 @@ public class Memtable implements Compara
 {
     private static final Logger logger = LoggerFactory.getLogger(Memtable.class);
 
-    private boolean isFrozen;
+    private volatile boolean isFrozen;
 
     private final AtomicLong currentThroughput = new AtomicLong(0);
     private final AtomicLong currentOperations = new AtomicLong(0);



Mime
View raw message