You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by be...@apache.org on 2016/05/18 21:00:44 UTC

[4/8] cassandra git commit: Fix deadlock on truncation with secondary index.

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/cassandra-3.7
Commit: 2837ec65b91abd78ec1bb37f1d69565b976e42e6
Parents: be65393
Author: Branimir Lambov <br...@datastax.com>
Authored: Tue May 17 12:22:21 2016 +0300
Committer: Benedict Elliott Smith <be...@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()