cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject [3/6] cassandra git commit: Fix deadlock on truncation with secondary index.
Date Wed, 18 May 2016 20:58:17 GMT
Fix deadlock on truncation with secondary index.

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

Branch: refs/heads/trunk
Commit: 2837ec65b91abd78ec1bb37f1d69565b976e42e6
Parents: be65393
Author: Branimir Lambov <branimir.lambov@datastax.com>
Authored: Tue May 17 12:22:21 2016 +0300
Committer: Benedict Elliott Smith <benedict@vast.com>
Committed: Wed May 18 21:49:39 2016 +0100

----------------------------------------------------------------------
 .../apache/cassandra/db/ColumnFamilyStore.java  | 32 +++++++++++---------
 1 file changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2837ec65/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 88e22c0..45486c1 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -2762,28 +2762,30 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         final long truncatedAt;
         final ReplayPosition replayAfter;
 
-        synchronized (data)
+        if (keyspace.getMetadata().durableWrites || takeSnapshot)
         {
-            if (keyspace.getMetadata().durableWrites || takeSnapshot)
-            {
-                replayAfter = forceBlockingFlush();
-            }
-            else
+            replayAfter = forceBlockingFlush();
+        }
+        else
+        {
+            // just nuke the memtable data w/o writing to disk first
+            Future<ReplayPosition> replayAfterFuture;
+            synchronized (data)
             {
-                // just nuke the memtable data w/o writing to disk first
                 final Flush flush = new Flush(true);
                 flushExecutor.execute(flush);
-                replayAfter = FBUtilities.waitOnFuture(postFlushExecutor.submit(flush.postFlush));
+                replayAfterFuture = postFlushExecutor.submit(flush.postFlush);
             }
-
-            long now = System.currentTimeMillis();
-            // make sure none of our sstables are somehow in the future (clock drift, perhaps)
-            for (ColumnFamilyStore cfs : concatWithIndexes())
-                for (SSTableReader sstable : cfs.data.getSSTables())
-                    now = Math.max(now, sstable.maxDataAge);
-            truncatedAt = now;
+            replayAfter = FBUtilities.waitOnFuture(replayAfterFuture);
         }
 
+        long now = System.currentTimeMillis();
+        // make sure none of our sstables are somehow in the future (clock drift, perhaps)
+        for (ColumnFamilyStore cfs : concatWithIndexes())
+            for (SSTableReader sstable : cfs.data.getSSTables())
+                now = Math.max(now, sstable.maxDataAge);
+        truncatedAt = now;
+
         Runnable truncateRunnable = new Runnable()
         {
             public void run()


Mime
View raw message