Repository: cassandra Updated Branches: refs/heads/cassandra-2.2 be653932d -> 2837ec65b refs/heads/cassandra-3.0 958183fad -> 5a5d0a1eb refs/heads/trunk 5bdf3184b -> bc7846680
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-2.2 Commit: 2837ec65b91abd78ec1bb37f1d69565b976e42e6 Parents: be65393 Author: Branimir Lambov <branimir.lam...@datastax.com> Authored: Tue May 17 12:22:21 2016 +0300 Committer: Benedict Elliott Smith <bened...@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()