Repository: phoenix
Updated Branches:
  refs/heads/5.x-HBase-2.0 09bd6983c -> 1b2c95094


PHOENIX-4671 Fix minor size accounting bug for MutationSize(Lars Hofhansl)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1b2c9509
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1b2c9509
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1b2c9509

Branch: refs/heads/5.x-HBase-2.0
Commit: 1b2c95094701bf62e1f646ba33d070aba0ac3d94
Parents: 09bd698
Author: Rajeshbabu Chintaguntla <rajeshb...@apache.org>
Authored: Thu May 24 16:33:15 2018 +0530
Committer: Rajeshbabu Chintaguntla <rajeshb...@apache.org>
Committed: Thu May 24 16:33:15 2018 +0530

----------------------------------------------------------------------
 .../end2end/UpsertSelectAutoCommitIT.java       | 28 ++++++++++++++++++++
 .../apache/phoenix/execute/MutationState.java   |  1 +
 2 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1b2c9509/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java
index 6b781a0..38d48d6 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java
@@ -23,15 +23,19 @@ import static 
org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.sql.Connection;
 import java.sql.Date;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Properties;
 
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.junit.Test;
@@ -173,4 +177,28 @@ public class UpsertSelectAutoCommitIT extends 
ParallelStatsDisabledIT {
         conn.close();
     }
 
+    @Test
+    public void testMaxMutationSize() throws Exception {
+        Properties connectionProperties = new Properties();
+        
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, "3");
+        
connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB, 
"50000");
+        PhoenixConnection connection =
+                (PhoenixConnection) DriverManager.getConnection(getUrl(), 
connectionProperties);
+        connection.setAutoCommit(true);
+        String fullTableName = generateUniqueName();
+        try (Statement stmt = connection.createStatement()) {
+            stmt.execute(
+                    "CREATE TABLE " + fullTableName + " (pk INTEGER PRIMARY 
KEY, v1 INTEGER, v2 INTEGER)");
+            stmt.execute(
+                    "CREATE SEQUENCE " + fullTableName + "_seq cache 1000");
+            stmt.execute("UPSERT INTO " + fullTableName + " VALUES (NEXT VALUE 
FOR " + fullTableName + "_seq, rand(), rand())");
+        }
+        try (Statement stmt = connection.createStatement()) {
+            for (int i=0; i<16; i++) {
+                stmt.execute("UPSERT INTO " + fullTableName + " SELECT NEXT 
VALUE FOR " + fullTableName + "_seq, rand(), rand() FROM " + fullTableName);
+            }
+        }
+        connection.close();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1b2c9509/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java 
b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
index 1d95f08..1d662ab 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
@@ -1581,6 +1581,7 @@ public class MutationState implements SQLCloseable {
         
         public void clear(){
             rowKeyToRowMutationState.clear();
+            estimatedSize = 0;
         }
         
         public Collection<RowMutationState> values() {

Reply via email to