From commits-return-19567-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Fri Feb 16 17:43:55 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id DA59818067B for ; Fri, 16 Feb 2018 17:43:54 +0100 (CET) Received: (qmail 88251 invoked by uid 500); 16 Feb 2018 16:43:53 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 88177 invoked by uid 99); 16 Feb 2018 16:43:53 -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; Fri, 16 Feb 2018 16:43:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 89285E00A4; Fri, 16 Feb 2018 16:43:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pboado@apache.org To: commits@phoenix.apache.org Date: Fri, 16 Feb 2018 16:43:53 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/4] phoenix git commit: PHOENIX-4591 Possible IndexOutOfBoundsException with delete query on bigger table(Rajeshbabu) Repository: phoenix Updated Branches: refs/heads/4.x-cdh5.11.2 2063e0f1a -> 1b14b6215 PHOENIX-4591 Possible IndexOutOfBoundsException with delete query on bigger table(Rajeshbabu) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/b2d3f274 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b2d3f274 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b2d3f274 Branch: refs/heads/4.x-cdh5.11.2 Commit: b2d3f274dba5b1e646fb79c1fc3190a4703b6721 Parents: 2063e0f Author: Rajeshbabu Chintaguntla Authored: Mon Feb 12 08:16:42 2018 +0000 Committer: Pedro Boado Committed: Fri Feb 16 16:36:36 2018 +0000 ---------------------------------------------------------------------- .../org/apache/phoenix/end2end/DeleteIT.java | 36 ++++++++++++++++++++ .../apache/phoenix/compile/DeleteCompiler.java | 4 ++- 2 files changed, 39 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/b2d3f274/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java index 498aeff..5e65927 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; @@ -33,7 +34,10 @@ import java.sql.Types; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Properties; +import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; import org.junit.Test; @@ -799,6 +803,38 @@ public class DeleteIT extends ParallelStatsDisabledIT { } } } + + @Test + public void testDeleteShouldNotFailWhenTheRowsMoreThanMaxMutationSize() throws Exception { + String tableName = generateUniqueName(); + String indexName1 = generateUniqueName(); + String ddl = + "CREATE TABLE IF NOT EXISTS " + + tableName + + " (pk1 DECIMAL NOT NULL, v1 VARCHAR, v2 VARCHAR CONSTRAINT PK PRIMARY KEY (pk1))" + + " IMMUTABLE_ROWS=true"; + String idx1 = "CREATE INDEX " + indexName1 + " ON " + tableName + "(v1)"; + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + props.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB,Integer.toString(10)); + try (Connection conn = DriverManager.getConnection(getUrl(), props)) { + conn.createStatement().execute(ddl); + conn.createStatement().execute(idx1); + Statement stmt = conn.createStatement(); + for(int i = 0; i < 20; i++) { + stmt.executeUpdate("UPSERT INTO " + tableName + " VALUES ("+i+",'value"+i+"', 'value2')"); + if (i % 10 == 0) { + conn.commit(); + } + } + conn.commit(); + conn.setAutoCommit(true); + try { + conn.createStatement().execute("DELETE FROM " + tableName); + } catch (Exception e) { + fail("Should not throw any exception"); + } + } + } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/b2d3f274/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java index 5670536..70043bb 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java @@ -258,7 +258,9 @@ public class DeleteCompiler { connection.getMutationState().send(); mutations.clear(); if (otherMutations != null) { - otherMutations.clear(); + for(MultiRowMutationState multiRowMutationState: otherMutations) { + multiRowMutationState.clear(); + } } } }