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 08F99200C47 for ; Thu, 30 Mar 2017 13:40:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0760D160B78; Thu, 30 Mar 2017 11:40:01 +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 1AA63160B8B for ; Thu, 30 Mar 2017 13:39:59 +0200 (CEST) Received: (qmail 61719 invoked by uid 500); 30 Mar 2017 11:39:59 -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 61626 invoked by uid 99); 30 Mar 2017 11:39:59 -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; Thu, 30 Mar 2017 11:39:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0282FE00FF; Thu, 30 Mar 2017 11:39:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: blambov@apache.org To: commits@cassandra.apache.org Date: Thu, 30 Mar 2017 11:39:59 -0000 Message-Id: <5aa96a3057bc4aea92bd2614866a2ef3@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/3] cassandra git commit: Fix testLimitSSTables flake caused by concurrent flush archived-at: Thu, 30 Mar 2017 11:40:01 -0000 Fix testLimitSSTables flake caused by concurrent flush Patch by Branimir Lambov; reviewed by Stefania Alborghetti for CASSANDRA-12820 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/81b88951 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/81b88951 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/81b88951 Branch: refs/heads/trunk Commit: 81b8895151742668ff5035960612d8c4325a1761 Parents: 0b1675d Author: Branimir Lambov Authored: Mon Jan 23 17:20:43 2017 +0200 Committer: Branimir Lambov Committed: Thu Mar 30 14:36:07 2017 +0300 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../org/apache/cassandra/db/KeyspaceTest.java | 74 ++++++++++++-------- 2 files changed, 46 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/81b88951/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 9cde2d8..3ead1d1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.11.0 + * Fix testLimitSSTables flake caused by concurrent flush (CASSANDRA-12820) * cdc column addition strikes again (CASSANDRA-13382) * Fix static column indexes (CASSANDRA-13277) * DataOutputBuffer.asNewBuffer broken (CASSANDRA-13298) http://git-wip-us.apache.org/repos/asf/cassandra/blob/81b88951/test/unit/org/apache/cassandra/db/KeyspaceTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/KeyspaceTest.java b/test/unit/org/apache/cassandra/db/KeyspaceTest.java index 5036749..f2a9984 100644 --- a/test/unit/org/apache/cassandra/db/KeyspaceTest.java +++ b/test/unit/org/apache/cassandra/db/KeyspaceTest.java @@ -24,6 +24,7 @@ import java.util.*; import org.apache.cassandra.Util; import org.apache.cassandra.cql3.CQLTester; import org.apache.cassandra.cql3.ColumnIdentifier; +import org.apache.cassandra.cql3.UntypedResultSet; import org.apache.cassandra.db.rows.Cell; import org.apache.cassandra.db.rows.Row; import org.apache.cassandra.db.rows.RowIterator; @@ -41,14 +42,34 @@ import static org.junit.Assert.*; public class KeyspaceTest extends CQLTester { + // Test needs synchronous table drop to avoid flushes causing flaky failures of testLimitSSTables + + @Override + protected String createTable(String query) + { + return super.createTable(KEYSPACE_PER_TEST, query); + } + + @Override + protected UntypedResultSet execute(String query, Object... values) throws Throwable + { + return executeFormattedQuery(formatQuery(KEYSPACE_PER_TEST, query), values); + } + + @Override + public ColumnFamilyStore getCurrentColumnFamilyStore() + { + return super.getCurrentColumnFamilyStore(KEYSPACE_PER_TEST); + } + @Test public void testGetRowNoColumns() throws Throwable { - String tableName = createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); + createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", "0", 0, 0); - final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName); + final ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); for (int round = 0; round < 2; round++) { @@ -69,12 +90,12 @@ public class KeyspaceTest extends CQLTester @Test public void testGetRowSingleColumn() throws Throwable { - String tableName = createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); + createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); for (int i = 0; i < 2; i++) execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", "0", i, i); - final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName); + final ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); for (int round = 0; round < 2; round++) { @@ -104,11 +125,11 @@ public class KeyspaceTest extends CQLTester @Test public void testGetSliceBloomFilterFalsePositive() throws Throwable { - String tableName = createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); + createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", "1", 1, 1); - final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName); + final ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); // check empty reads on the partitions before and after the existing one for (String key : new String[]{"0", "2"}) @@ -166,14 +187,13 @@ public class KeyspaceTest extends CQLTester @Test public void testGetSliceWithCutoff() throws Throwable { - // tests slicing against data from one row in a memtable and then flushed to an sstable - String tableName = createTable("CREATE TABLE %s (a text, b int, c text, PRIMARY KEY (a, b))"); + createTable("CREATE TABLE %s (a text, b int, c text, PRIMARY KEY (a, b))"); String prefix = "omg!thisisthevalue!"; for (int i = 0; i < 300; i++) execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", "0", i, prefix + i); - final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName); + final ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); for (int round = 0; round < 2; round++) { @@ -194,8 +214,8 @@ public class KeyspaceTest extends CQLTester @Test public void testReversedWithFlushing() throws Throwable { - String tableName = createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b)) WITH CLUSTERING ORDER BY (b DESC)"); - final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName); + createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b)) WITH CLUSTERING ORDER BY (b DESC)"); + final ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); for (int i = 0; i < 10; i++) execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", "0", i, i); @@ -206,7 +226,7 @@ public class KeyspaceTest extends CQLTester { execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", "0", i, i); - PartitionColumns columns = PartitionColumns.of(cfs.metadata.getColumnDefinition(new ColumnIdentifier("c", false))); + PartitionColumns.of(cfs.metadata.getColumnDefinition(new ColumnIdentifier("c", false))); ClusteringIndexSliceFilter filter = new ClusteringIndexSliceFilter(Slices.ALL, false); SinglePartitionReadCommand command = singlePartitionSlice(cfs, "0", filter, null); try (ReadExecutionController executionController = command.executionController(); @@ -273,9 +293,8 @@ public class KeyspaceTest extends CQLTester @Test public void testGetSliceFromBasic() throws Throwable { - // tests slicing against data from one row in a memtable and then flushed to an sstable - String tableName = createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); - final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName); + createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); + final ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); for (int i = 1; i < 10; i++) { @@ -322,9 +341,8 @@ public class KeyspaceTest extends CQLTester @Test public void testGetSliceWithExpiration() throws Throwable { - // tests slicing against data from one row with expiring column in a memtable and then flushed to an sstable - String tableName = createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); - final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName); + createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); + final ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", "0", 0, 0); execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?) USING TTL 60", "0", 1, 1); @@ -346,9 +364,8 @@ public class KeyspaceTest extends CQLTester @Test public void testGetSliceFromAdvanced() throws Throwable { - // tests slicing against data from one row spread across two sstables - String tableName = createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); - final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName); + createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); + final ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); for (int i = 1; i < 7; i++) execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", "0", i, i); @@ -372,9 +389,8 @@ public class KeyspaceTest extends CQLTester @Test public void testGetSliceFromLarge() throws Throwable { - // tests slicing against 1000 rows in an sstable - String tableName = createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); - final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName); + createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); + final ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); for (int i = 1000; i < 2000; i++) execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", "0", i, i); @@ -389,7 +405,7 @@ public class KeyspaceTest extends CQLTester // verify that we do indeed have multiple index entries SSTableReader sstable = cfs.getLiveSSTables().iterator().next(); - RowIndexEntry indexEntry = sstable.getPosition(Util.dk("0"), SSTableReader.Operator.EQ); + RowIndexEntry indexEntry = sstable.getPosition(Util.dk("0"), SSTableReader.Operator.EQ); assert indexEntry.columnsIndexCount() > 2; validateSliceLarge(cfs); @@ -398,8 +414,8 @@ public class KeyspaceTest extends CQLTester @Test public void testLimitSSTables() throws Throwable { - String tableName = createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); - final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName); + createTable("CREATE TABLE %s (a text, b int, c int, PRIMARY KEY (a, b))"); + final ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); cfs.disableAutoCompaction(); for (int j = 0; j < 10; j++) @@ -451,8 +467,8 @@ public class KeyspaceTest extends CQLTester // k |a0:90|a1:91|..|a9:99 // --------------------- // then we slice out col1 = a5 and col2 > 85 -> which should let us just check 2 sstables and get 2 columns - String tableName = createTable("CREATE TABLE %s (a text, b text, c int, d int, PRIMARY KEY (a, b, c))"); - final ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName); + createTable("CREATE TABLE %s (a text, b text, c int, d int, PRIMARY KEY (a, b, c))"); + final ColumnFamilyStore cfs = getCurrentColumnFamilyStore(); cfs.disableAutoCompaction(); for (int j = 0; j < 10; j++)