Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.3 d15efd1bf -> 3d67e8d5c


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

Branch: refs/heads/4.x-HBase-1.3
Commit: 3d67e8d5c614627dab7826c1273b0e440e49f73f
Parents: d15efd1
Author: Rajeshbabu Chintaguntla <rajeshb...@apache.org>
Authored: Mon Feb 12 13:37:21 2018 +0530
Committer: Rajeshbabu Chintaguntla <rajeshb...@apache.org>
Committed: Mon Feb 12 13:37:21 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/3d67e8d5/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/3d67e8d5/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();
+                        }
                     }
                 }
             }

Reply via email to