Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.2 e4566fcd7 -> ff4ad203b
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/ff4ad203 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ff4ad203 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ff4ad203 Branch: refs/heads/4.x-HBase-1.2 Commit: ff4ad203b5ac932506d06aa6496a7858031003c7 Parents: e4566fc Author: Rajeshbabu Chintaguntla <rajeshb...@apache.org> Authored: Mon Feb 12 13:46:42 2018 +0530 Committer: Rajeshbabu Chintaguntla <rajeshb...@apache.org> Committed: Mon Feb 12 13:46:42 2018 +0530 ---------------------------------------------------------------------- .../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/ff4ad203/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/ff4ad203/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 54e63d2..6e500c0 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 @@ -256,7 +256,9 @@ public class DeleteCompiler { connection.getMutationState().send(); mutations.clear(); if (otherMutations != null) { - otherMutations.clear(); + for(MultiRowMutationState multiRowMutationState: otherMutations) { + multiRowMutationState.clear(); + } } } }