You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ra...@apache.org on 2018/02/12 08:06:46 UTC

phoenix git commit: PHOENIX-4591 Possible IndexOutOfBoundsException with delete query on bigger table(Rajeshbabu)

Repository: phoenix
Updated Branches:
  refs/heads/master f5512105c -> a6bf7350d


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/a6bf7350
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a6bf7350
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a6bf7350

Branch: refs/heads/master
Commit: a6bf7350d311e42402d330b07cb412b422eeaae9
Parents: f551210
Author: Rajeshbabu Chintaguntla <ra...@apache.org>
Authored: Mon Feb 12 13:36:18 2018 +0530
Committer: Rajeshbabu Chintaguntla <ra...@apache.org>
Committed: Mon Feb 12 13:36:18 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/a6bf7350/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/a6bf7350/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();
+                        }
                     }
                 }
             }