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 79EAD200B58 for ; Wed, 27 Jul 2016 11:37:21 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 78AE1160AA8; Wed, 27 Jul 2016 09:37:21 +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 C78FC160A6E for ; Wed, 27 Jul 2016 11:37:20 +0200 (CEST) Received: (qmail 33073 invoked by uid 500); 27 Jul 2016 09:37: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 32982 invoked by uid 99); 27 Jul 2016 09:37:14 -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, 27 Jul 2016 09:37:14 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BD15CE02E4; Wed, 27 Jul 2016 09:37:14 +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: Wed, 27 Jul 2016 09:37:15 -0000 Message-Id: <30727db816b042ed9eaefc043bc77777@git.apache.org> In-Reply-To: <00170b59a3cf496682731d60613dd251@git.apache.org> References: <00170b59a3cf496682731d60613dd251@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/6] cassandra git commit: AssertionError with MVs on updating a row that isn't indexed due to a null value archived-at: Wed, 27 Jul 2016 09:37:21 -0000 AssertionError with MVs on updating a row that isn't indexed due to a null value patch by Sylvain Lebresne; reviewed by Carl Yeksigian for CASSANDRA-12247 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/8d020e25 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/8d020e25 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/8d020e25 Branch: refs/heads/cassandra-3.9 Commit: 8d020e25c0bc9dc7e0d0201974d16ba72381172e Parents: 1608699 Author: Sylvain Lebresne Authored: Mon Jul 25 16:35:33 2016 +0200 Committer: Sylvain Lebresne Committed: Wed Jul 27 11:26:10 2016 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../cassandra/db/view/ViewUpdateGenerator.java | 4 +-- .../org/apache/cassandra/cql3/ViewTest.java | 29 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/8d020e25/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 3c485dd..90f1ee9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.0.9 + * AssertionError with MVs on updating a row that isn't indexed due to a null value (CASSANDRA-12247) * Disable RR and speculative retry with EACH_QUORUM reads (CASSANDRA-11980) * Add option to override compaction space check (CASSANDRA-12180) * Faster startup by only scanning each directory for temporary files once (CASSANDRA-12114) http://git-wip-us.apache.org/repos/asf/cassandra/blob/8d020e25/src/java/org/apache/cassandra/db/view/ViewUpdateGenerator.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/view/ViewUpdateGenerator.java b/src/java/org/apache/cassandra/db/view/ViewUpdateGenerator.java index af025cb..3bdc380 100644 --- a/src/java/org/apache/cassandra/db/view/ViewUpdateGenerator.java +++ b/src/java/org/apache/cassandra/db/view/ViewUpdateGenerator.java @@ -191,7 +191,7 @@ public class ViewUpdateGenerator // If the update didn't modified this column, the cells will be the same object so it's worth checking if (before == after) - return before == null ? UpdateAction.NONE : UpdateAction.UPDATE_EXISTING; + return isLive(before) ? UpdateAction.UPDATE_EXISTING : UpdateAction.NONE; if (!isLive(before)) return isLive(after) ? UpdateAction.NEW_ENTRY : UpdateAction.NONE; @@ -452,7 +452,7 @@ public class ViewUpdateGenerator ColumnDefinition baseColumn = view.baseNonPKColumnsInViewPK.get(0); Cell cell = baseRow.getCell(baseColumn); - assert isLive(cell) : "We shouldn't have got there is the base row had no associated entry"; + assert isLive(cell) : "We shouldn't have got there if the base row had no associated entry"; long timestamp = Math.max(baseLiveness.timestamp(), cell.timestamp()); return LivenessInfo.create(timestamp, cell.ttl(), cell.localDeletionTime()); http://git-wip-us.apache.org/repos/asf/cassandra/blob/8d020e25/test/unit/org/apache/cassandra/cql3/ViewTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/ViewTest.java b/test/unit/org/apache/cassandra/cql3/ViewTest.java index 85f01a6..c9ef401 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewTest.java @@ -1108,4 +1108,33 @@ public class ViewTest extends CQLTester } } + + @Test + public void testNullInClusteringColumns() throws Throwable + { + createTable("CREATE TABLE %s (id1 int, id2 int, v1 text, v2 text, PRIMARY KEY (id1, id2))"); + + executeNet(protocolVersion, "USE " + keyspace()); + + createView("mv", + "CREATE MATERIALIZED VIEW %s AS" + + " SELECT id1, v1, id2, v2" + + " FROM %%s" + + " WHERE id1 IS NOT NULL AND v1 IS NOT NULL AND id2 IS NOT NULL" + + " PRIMARY KEY (id1, v1, id2)" + + " WITH CLUSTERING ORDER BY (v1 DESC, id2 ASC)"); + + execute("INSERT INTO %s (id1, id2, v1, v2) VALUES (?, ?, ?, ?)", 0, 1, "foo", "bar"); + + assertRowsNet(protocolVersion, executeNet(protocolVersion, "SELECT * FROM %s"), row(0, 1, "foo", "bar")); + assertRowsNet(protocolVersion, executeNet(protocolVersion, "SELECT * FROM mv"), row(0, "foo", 1, "bar")); + + executeNet(protocolVersion, "UPDATE %s SET v1=? WHERE id1=? AND id2=?", null, 0, 1); + assertRowsNet(protocolVersion, executeNet(protocolVersion, "SELECT * FROM %s"), row(0, 1, null, "bar")); + assertRowsNet(protocolVersion, executeNet(protocolVersion, "SELECT * FROM mv")); + + executeNet(protocolVersion, "UPDATE %s SET v2=? WHERE id1=? AND id2=?", "rab", 0, 1); + assertRowsNet(protocolVersion, executeNet(protocolVersion, "SELECT * FROM %s"), row(0, 1, null, "rab")); + assertRowsNet(protocolVersion, executeNet(protocolVersion, "SELECT * FROM mv")); + } }