[1/4] phoenix git commit: PHOENIX-4591 Possible IndexOutOfBoundsException with delete query on bigger table(Rajeshbabu)

2018-02-16 Thread pboado
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 +
Committer: Pedro Boado 
Committed: Fri Feb 16 16:36:36 2018 +

--
 .../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();
+}
 }
 }
 }



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

2018-02-12 Thread rajeshbabu
Repository: phoenix
Updated Branches:
  refs/heads/5.x-HBase-2.0 8c1746c21 -> 7cb65d155


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

Branch: refs/heads/5.x-HBase-2.0
Commit: 7cb65d155b716aa1a4bb6179fe440b1e5f6d79e9
Parents: 8c1746c
Author: Rajeshbabu Chintaguntla 
Authored: Mon Feb 12 14:22:38 2018 +0530
Committer: Rajeshbabu Chintaguntla 
Committed: Mon Feb 12 14:22:38 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/7cb65d15/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/7cb65d15/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 b77fcbe..53fc398 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
@@ -239,7 +239,9 @@ public class DeleteCompiler {
 connection.getMutationState().send();
 mutations.clear();
 if (indexMutations != null) {
-indexMutations.clear();
+for (Map 
multiRowMutationState : indexMutations) {
+multiRowMutationState.clear();
+}
 }
 }
 }



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

2018-02-12 Thread rajeshbabu
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 587f78de2 -> 66fc54c68


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

Branch: refs/heads/4.x-HBase-1.1
Commit: 66fc54c689ce9c809d55cef91bc0b316f5cb5ca0
Parents: 587f78d
Author: Rajeshbabu Chintaguntla 
Authored: Mon Feb 12 14:00:20 2018 +0530
Committer: Rajeshbabu Chintaguntla 
Committed: Mon Feb 12 14:00:20 2018 +0530

--
 .../org/apache/phoenix/end2end/DeleteIT.java| 37 
 .../apache/phoenix/compile/DeleteCompiler.java  |  4 ++-
 2 files changed, 40 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/66fc54c6/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 6e4cb2a..c31fdd9 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,9 +17,11 @@
  */
 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;
+import static org.junit.Assert.fail;
 
 import java.sql.Connection;
 import java.sql.Date;
@@ -32,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;
 
@@ -769,6 +774,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/66fc54c6/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 bc96627..46f4542 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
@@ -255,7 +255,9 @@ public class DeleteCompiler {
 connection.getMutationState().send();
 mutations.clear();
 if (otherMutations != null) {
-otherMutations.clear();
+for(MultiRowMutationState multiRowMutationState: 
otherMutations) {
+multiRowMutationState.clear();
+}
 }
 }
 }



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

2018-02-12 Thread rajeshbabu
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 
Authored: Mon Feb 12 13:46:42 2018 +0530
Committer: Rajeshbabu Chintaguntla 
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();
+}
 }
 }
 }



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

2018-02-12 Thread rajeshbabu
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 1d34ad38b -> c9e23eac5


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

Branch: refs/heads/4.x-HBase-0.98
Commit: c9e23eac59bba3f3dc1df9079a31a31b16afd39c
Parents: 1d34ad3
Author: Rajeshbabu Chintaguntla 
Authored: Mon Feb 12 13:44:49 2018 +0530
Committer: Rajeshbabu Chintaguntla 
Committed: Mon Feb 12 13:44:49 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/c9e23eac/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/c9e23eac/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();
+}
 }
 }
 }



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

2018-02-12 Thread rajeshbabu
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 
Authored: Mon Feb 12 13:37:21 2018 +0530
Committer: Rajeshbabu Chintaguntla 
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();
+}
 }
 }
 }



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

2018-02-12 Thread 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 
Authored: Mon Feb 12 13:36:18 2018 +0530
Committer: Rajeshbabu Chintaguntla 
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();
+}
 }
 }
 }