Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 52368200ACA for ; Wed, 18 May 2016 22:58:17 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 50F43160A27; Wed, 18 May 2016 20:58:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9BA96160A00 for ; Wed, 18 May 2016 22:58:16 +0200 (CEST) Received: (qmail 19721 invoked by uid 500); 18 May 2016 20:58:15 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 19539 invoked by uid 99); 18 May 2016 20:58:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 May 2016 20:58:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 82598E020F; Wed, 18 May 2016 20:58:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: benedict@apache.org To: commits@cassandra.apache.org Date: Wed, 18 May 2016 20:58:17 -0000 Message-Id: <8410644e031544e9897df253a04ffa18@git.apache.org> In-Reply-To: <45dfc3e24f664699a4a63f56a4450709@git.apache.org> References: <45dfc3e24f664699a4a63f56a4450709@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/6] cassandra git commit: Fix deadlock on truncation with secondary index. archived-at: Wed, 18 May 2016 20:58:17 -0000 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 Authored: Tue May 17 12:22:21 2016 +0300 Committer: Benedict Elliott Smith 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 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()