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 3E85B200B4C for ; Thu, 7 Jul 2016 13:03:38 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3C081160A85; Thu, 7 Jul 2016 11:03:38 +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 58A8D160A59 for ; Thu, 7 Jul 2016 13:03:37 +0200 (CEST) Received: (qmail 55613 invoked by uid 500); 7 Jul 2016 11:03:36 -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 55588 invoked by uid 99); 7 Jul 2016 11:03:36 -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, 07 Jul 2016 11:03:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 18E51E07FE; Thu, 7 Jul 2016 11:03:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: slebresne@apache.org To: commits@cassandra.apache.org Date: Thu, 07 Jul 2016 11:03:36 -0000 Message-Id: <1c2d04968cb84bebb1ebb4a93d4ec007@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/9] cassandra git commit: NPE when trying to remove purgable tombstones from result archived-at: Thu, 07 Jul 2016 11:03:38 -0000 Repository: cassandra Updated Branches: refs/heads/cassandra-3.0 30f5d44d8 -> 76e68e9b4 refs/heads/cassandra-3.9 376dae268 -> a006f577b refs/heads/trunk 9fd607778 -> 3016dc7c2 NPE when trying to remove purgable tombstones from result patch by mck; reviewed by Sylvain Lebresne for CASSANDRA-12143 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ef18a176 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ef18a176 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ef18a176 Branch: refs/heads/trunk Commit: ef18a1768a6589eac212a7f320f9748ca6dc8371 Parents: 00e7ecf Author: mck Authored: Thu Jul 7 11:17:40 2016 +0200 Committer: Sylvain Lebresne Committed: Thu Jul 7 12:49:12 2016 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/db/ColumnFamilyStore.java | 3 +- .../cassandra/db/ColumnFamilyStoreTest.java | 50 ++++++++++++++++---- 3 files changed, 44 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/ef18a176/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 7d62f97..e10af6f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 2.2.8 + * NPE when trying to remove purgable tombstones from result (CASSANDRA-12143) * Improve streaming synchronization and fault tolerance (CASSANDRA-11414) * MemoryUtil.getShort() should return an unsigned short also for architectures not supporting unaligned memory accesses (CASSANDRA-11973) Merged from 2.1: http://git-wip-us.apache.org/repos/asf/cassandra/blob/ef18a176/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 d86f941..ff63163 100644 --- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java +++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java @@ -2347,7 +2347,8 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean } // remove purgable tombstones from result - see CASSANDRA-11427 - data.purgeTombstones(gcBefore(filter.timestamp)); + if (data != null) + data.purgeTombstones(gcBefore(filter.timestamp)); rows.add(new Row(rawRow.key, data)); if (!ignoreTombstonedPartitions || !data.hasOnlyTombstones(filter.timestamp)) http://git-wip-us.apache.org/repos/asf/cassandra/blob/ef18a176/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java index 5419ef5..2d67baf 100644 --- a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java +++ b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java @@ -66,6 +66,7 @@ import org.apache.cassandra.db.composites.CellNameType; import org.apache.cassandra.db.composites.CellNames; import org.apache.cassandra.db.composites.Composites; import org.apache.cassandra.db.filter.ColumnSlice; +import org.apache.cassandra.db.filter.ExtendedFilter; import org.apache.cassandra.db.filter.IDiskAtomFilter; import org.apache.cassandra.db.filter.NamesQueryFilter; import org.apache.cassandra.db.filter.QueryFilter; @@ -94,7 +95,6 @@ import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.FBUtilities; import org.apache.cassandra.utils.Pair; import org.apache.cassandra.utils.WrappedRunnable; -import org.apache.thrift.TException; import static org.apache.cassandra.Util.cellname; import static org.apache.cassandra.Util.column; @@ -246,6 +246,38 @@ public class ColumnFamilyStoreTest } @Test + public void testFilterWithNullCF() throws Exception + { + Keyspace keyspace = Keyspace.open(KEYSPACE1); + ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARD1); + final Row row = new Row(Util.dk("key1"), null); + + ColumnFamilyStore.AbstractScanIterator iterator = new ColumnFamilyStore.AbstractScanIterator() + { + Iterator it = Collections.singletonList(row).iterator(); + + protected Row computeNext() + { + return it.hasNext() ? it.next() : endOfData(); + } + + @Override + public void close() + { + } + }; + + ExtendedFilter filter = ExtendedFilter.create( + cfs, + DataRange.allData(DatabaseDescriptor.getPartitioner()), null, 1, true, System.currentTimeMillis()); + + List list = cfs.filter(iterator, filter); + assert 1 == list.size(); + assert list.get(0).key == row.key; + assert null == list.get(0).cf; + } + + @Test public void testSkipStartKey() { ColumnFamilyStore cfs = insertKey1Key2(); @@ -571,7 +603,7 @@ public class ColumnFamilyStoreTest cfs.truncateBlocking(); ByteBuffer rowKey = ByteBufferUtil.bytes("k1"); - CellName colName = cellname("birthdate"); + CellName colName = cellname("birthdate"); ByteBuffer val1 = ByteBufferUtil.bytes(1L); ByteBuffer val2 = ByteBufferUtil.bytes(2L); @@ -635,7 +667,7 @@ public class ColumnFamilyStoreTest ByteBuffer rowKey = ByteBufferUtil.bytes("k1"); ByteBuffer clusterKey = ByteBufferUtil.bytes("ck1"); - ByteBuffer colName = ByteBufferUtil.bytes("col1"); + ByteBuffer colName = ByteBufferUtil.bytes("col1"); CellNameType baseComparator = cfs.getComparator(); CellName compositeName = baseComparator.makeCellName(clusterKey, colName); @@ -2291,7 +2323,7 @@ public class ColumnFamilyStoreTest }); System.err.println("Row key: " + rowKey + " Cols: " + transformed); } - + @Test public void testRebuildSecondaryIndex() throws IOException { @@ -2303,19 +2335,19 @@ public class ColumnFamilyStoreTest rm.apply(); assertTrue(Arrays.equals("k1".getBytes(), PerRowSecondaryIndexTest.TestIndex.LAST_INDEXED_KEY.array())); - + Keyspace.open("PerRowSecondaryIndex").getColumnFamilyStore("Indexed1").forceBlockingFlush(); - + PerRowSecondaryIndexTest.TestIndex.reset(); - + ColumnFamilyStore.rebuildSecondaryIndex("PerRowSecondaryIndex", "Indexed1", PerRowSecondaryIndexTest.TestIndex.class.getSimpleName()); assertTrue(Arrays.equals("k1".getBytes(), PerRowSecondaryIndexTest.TestIndex.LAST_INDEXED_KEY.array())); - + PerRowSecondaryIndexTest.TestIndex.reset(); PerRowSecondaryIndexTest.TestIndex.ACTIVE = false; ColumnFamilyStore.rebuildSecondaryIndex("PerRowSecondaryIndex", "Indexed1", PerRowSecondaryIndexTest.TestIndex.class.getSimpleName()); assertNull(PerRowSecondaryIndexTest.TestIndex.LAST_INDEXED_KEY); - + PerRowSecondaryIndexTest.TestIndex.reset(); } }