You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ch...@apache.org on 2020/01/09 01:33:41 UTC
[phoenix] branch 4.15-HBase-1.3 updated: PHOENIX: 5630
MAX_MUTATION_SIZE_EXCEEDED and MAX_MUTATION_SIZE_BYTES_EXCEEDED
SQLExceptions should print existing size
This is an automated email from the ASF dual-hosted git repository.
chinmayskulkarni pushed a commit to branch 4.15-HBase-1.3
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.15-HBase-1.3 by this push:
new ee91434 PHOENIX: 5630 MAX_MUTATION_SIZE_EXCEEDED and MAX_MUTATION_SIZE_BYTES_EXCEEDED SQLExceptions should print existing size
ee91434 is described below
commit ee91434530bd9c9bc9c9f8516e89499546eca8c8
Author: Neha <ne...@salesforce.com>
AuthorDate: Wed Jan 8 13:28:20 2020 -0800
PHOENIX: 5630 MAX_MUTATION_SIZE_EXCEEDED and MAX_MUTATION_SIZE_BYTES_EXCEEDED SQLExceptions should print existing size
Signed-off-by: Chinmay Kulkarni <ch...@apache.org>
---
.../apache/phoenix/end2end/MutationStateIT.java | 4 ++
.../apache/phoenix/exception/SQLExceptionCode.java | 19 +++++--
.../apache/phoenix/exception/SQLExceptionInfo.java | 61 ++++++++++++++++++++++
.../org/apache/phoenix/execute/MutationState.java | 41 ++++++++-------
.../MaxMutationSizeBytesExceededException.java | 49 +++++++++++++++++
.../schema/MaxMutationSizeExceededException.java | 45 ++++++++++++++++
6 files changed, 198 insertions(+), 21 deletions(-)
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
index c71e2e8..096826d 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java
@@ -366,6 +366,8 @@ public class MutationStateIT extends ParallelStatsDisabledIT {
e.getErrorCode());
assertTrue(e.getMessage().contains(
SQLExceptionCode.MAX_MUTATION_SIZE_EXCEEDED.getMessage()));
+ assertTrue(e.getMessage().contains(
+ connectionProperties.getProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB)));
}
// set the max mutation size (bytes) to a low value
@@ -381,6 +383,8 @@ public class MutationStateIT extends ParallelStatsDisabledIT {
e.getErrorCode());
assertTrue(e.getMessage().contains(
SQLExceptionCode.MAX_MUTATION_SIZE_BYTES_EXCEEDED.getMessage()));
+ assertTrue(e.getMessage().contains(connectionProperties.getProperty
+ (QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB)));
}
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
index 559b52e..54b12ba 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
@@ -47,6 +47,8 @@ import org.apache.phoenix.schema.TableAlreadyExistsException;
import org.apache.phoenix.schema.TableNotFoundException;
import org.apache.phoenix.schema.TypeMismatchException;
import org.apache.phoenix.schema.types.PDataType;
+import org.apache.phoenix.schema.MaxMutationSizeBytesExceededException;
+import org.apache.phoenix.schema.MaxMutationSizeExceededException;
import org.apache.phoenix.util.MetaDataUtil;
import com.google.common.collect.Maps;
@@ -478,13 +480,24 @@ public enum SQLExceptionCode {
NEW_CONNECTION_THROTTLED(728, "410M1", "Could not create connection " +
"because this client already has the maximum number" +
" of connections to the target cluster."),
-
MAX_MUTATION_SIZE_EXCEEDED(729, "LIM01", "MutationState size is bigger" +
" than maximum allowed number of rows, try upserting rows in smaller batches or " +
- "using autocommit on for deletes."),
+ "using autocommit on for deletes.", new Factory() {
+ @Override
+ public SQLException newException(SQLExceptionInfo info) {
+ return new MaxMutationSizeExceededException(
+ info.getMaxMutationSize(), info.getMutationSize());
+ }
+ }),
MAX_MUTATION_SIZE_BYTES_EXCEEDED(730, "LIM02", "MutationState size is " +
"bigger than maximum allowed number of bytes, try upserting rows in smaller batches " +
- "or using autocommit on for deletes."),
+ "or using autocommit on for deletes.", new Factory() {
+ @Override
+ public SQLException newException(SQLExceptionInfo info) {
+ return new MaxMutationSizeBytesExceededException(info.getMaxMutationSizeBytes(),
+ info.getMutationSizeBytes());
+ }
+ }),
INSUFFICIENT_MEMORY(999, "50M01", "Unable to allocate enough memory."),
HASH_JOIN_CACHE_NOT_FOUND(900, "HJ01", "Hash Join cache not found"),
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionInfo.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionInfo.java
index 1c3694d..4681ac3 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionInfo.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionInfo.java
@@ -38,6 +38,10 @@ public class SQLExceptionInfo {
public static final String FAMILY_NAME = "familyName";
public static final String COLUMN_NAME = "columnName";
public static final String FUNCTION_NAME = "functionName";
+ public static final String MAX_MUTATION_SIZE = "maxMutationSize";
+ public static final String MUTATION_SIZE = "mutationSize";
+ public static final String MAX_MUTATION_SIZE_BYTES = "maxMutationSizeBytes";
+ public static final String MUTATION_SIZE_BYTES = "mutationSizeBytes";
private final Throwable rootCause;
private final SQLExceptionCode code; // Should always have one.
@@ -47,6 +51,10 @@ public class SQLExceptionInfo {
private final String familyName;
private final String columnName;
private final String functionName;
+ private final int maxMutationSize;
+ private final int mutationSize;
+ private final long maxMutationSizeBytes;
+ private final long mutationSizeBytes;
public static class Builder {
@@ -58,6 +66,10 @@ public class SQLExceptionInfo {
private String familyName;
private String columnName;
private String functionName;
+ private int maxMutationSize;
+ private int mutationSize;
+ private long maxMutationSizeBytes;
+ private long mutationSizeBytes;
public Builder(SQLExceptionCode code) {
this.code = code;
@@ -97,6 +109,27 @@ public class SQLExceptionInfo {
this.functionName = functionName;
return this;
}
+
+ public Builder setMaxMutationSize(int maxMutationSize) {
+ this.maxMutationSize = maxMutationSize;
+ return this;
+ }
+
+ public Builder setMutationSize(int mutationSize) {
+ this.mutationSize = mutationSize;
+ return this;
+ }
+
+ public Builder setMaxMutationSizeBytes(long maxMutationSizeBytes) {
+ this.maxMutationSizeBytes = maxMutationSizeBytes;
+ return this;
+ }
+
+ public Builder setMutationSizeBytes(long mutationSizeBytes) {
+ this.mutationSizeBytes = mutationSizeBytes;
+ return this;
+ }
+
public SQLExceptionInfo build() {
return new SQLExceptionInfo(this);
}
@@ -116,6 +149,10 @@ public class SQLExceptionInfo {
familyName = builder.familyName;
columnName = builder.columnName;
functionName = builder.functionName;
+ maxMutationSize = builder.maxMutationSize;
+ mutationSize = builder.mutationSize;
+ maxMutationSizeBytes = builder.maxMutationSizeBytes;
+ mutationSizeBytes = builder.mutationSizeBytes;
}
@Override
@@ -143,6 +180,14 @@ public class SQLExceptionInfo {
} else if (schemaName != null) {
builder.append(" ").append(SCHEMA_NAME).append("=").append(columnDisplayName);
}
+ if (maxMutationSize != 0) {
+ builder.append(" ").append(MAX_MUTATION_SIZE).append("=").append(maxMutationSize);
+ builder.append(" ").append(MUTATION_SIZE).append("=").append(mutationSize);
+ } else if (maxMutationSizeBytes != 0) {
+ builder.append(" ").append(MAX_MUTATION_SIZE_BYTES).append("=").
+ append(maxMutationSizeBytes);
+ builder.append(" ").append(MUTATION_SIZE_BYTES).append("=").append(mutationSizeBytes);
+ }
return builder.toString();
}
@@ -182,4 +227,20 @@ public class SQLExceptionInfo {
return message;
}
+ public int getMaxMutationSize() {
+ return maxMutationSize;
+ }
+
+ public int getMutationSize() {
+ return mutationSize;
+ }
+
+ public long getMaxMutationSizeBytes() {
+ return maxMutationSizeBytes;
+ }
+
+ public long getMutationSizeBytes() {
+ return mutationSizeBytes;
+ }
+
}
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 a196f9a..b10d44a 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
@@ -76,6 +76,7 @@ import org.apache.phoenix.monitoring.ReadMetricQueue;
import org.apache.phoenix.query.QueryConstants;
import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.query.QueryServicesOptions;
+import org.apache.phoenix.schema.ValueSchema.Field;
import org.apache.phoenix.schema.IllegalDataException;
import org.apache.phoenix.schema.MetaDataClient;
import org.apache.phoenix.schema.PColumn;
@@ -89,9 +90,10 @@ import org.apache.phoenix.schema.PTableType;
import org.apache.phoenix.schema.RowKeySchema;
import org.apache.phoenix.schema.TableNotFoundException;
import org.apache.phoenix.schema.TableRef;
-import org.apache.phoenix.schema.ValueSchema.Field;
import org.apache.phoenix.schema.types.PLong;
import org.apache.phoenix.schema.types.PTimestamp;
+import org.apache.phoenix.schema.MaxMutationSizeBytesExceededException;
+import org.apache.phoenix.schema.MaxMutationSizeExceededException;
import org.apache.phoenix.trace.util.Tracing;
import org.apache.phoenix.transaction.PhoenixTransactionContext;
import org.apache.phoenix.transaction.PhoenixTransactionContext.PhoenixVisibilityLevel;
@@ -126,7 +128,7 @@ public class MutationState implements SQLCloseable {
private static final int MAX_COMMIT_RETRIES = 3;
private final PhoenixConnection connection;
- private final long maxSize;
+ private final int maxSize;
private final long maxSizeBytes;
private final long batchSize;
private final long batchSizeBytes;
@@ -146,12 +148,12 @@ public class MutationState implements SQLCloseable {
private final MutationMetricQueue mutationMetricQueue;
private ReadMetricQueue readMetricQueue;
- public MutationState(long maxSize, long maxSizeBytes, PhoenixConnection connection) {
+ public MutationState(int maxSize, long maxSizeBytes, PhoenixConnection connection) {
this(maxSize, maxSizeBytes, connection, false, null);
}
- public MutationState(long maxSize, long maxSizeBytes, PhoenixConnection connection,
- PhoenixTransactionContext txContext) {
+ public MutationState(int maxSize, long maxSizeBytes, PhoenixConnection connection,
+ PhoenixTransactionContext txContext) {
this(maxSize, maxSizeBytes, connection, false, txContext);
}
@@ -164,23 +166,24 @@ public class MutationState implements SQLCloseable {
.getPhoenixTransactionContext());
}
- public MutationState(long maxSize, long maxSizeBytes, PhoenixConnection connection, long sizeOffset) {
+ public MutationState(int maxSize, long maxSizeBytes, PhoenixConnection connection,
+ long sizeOffset) {
this(maxSize, maxSizeBytes, connection, false, null, sizeOffset);
}
- private MutationState(long maxSize, long maxSizeBytes, PhoenixConnection connection, boolean subTask,
- PhoenixTransactionContext txContext) {
+ private MutationState(int maxSize, long maxSizeBytes, PhoenixConnection connection,
+ boolean subTask, PhoenixTransactionContext txContext) {
this(maxSize, maxSizeBytes, connection, subTask, txContext, 0);
}
- private MutationState(long maxSize, long maxSizeBytes, PhoenixConnection connection, boolean subTask,
- PhoenixTransactionContext txContext, long sizeOffset) {
+ private MutationState(int maxSize, long maxSizeBytes, PhoenixConnection connection,
+ boolean subTask, PhoenixTransactionContext txContext, long sizeOffset) {
this(maxSize, maxSizeBytes, connection, Maps.<TableRef, MultiRowMutationState> newHashMapWithExpectedSize(5),
subTask, txContext);
this.sizeOffset = sizeOffset;
}
- MutationState(long maxSize, long maxSizeBytes, PhoenixConnection connection,
+ MutationState(int maxSize, long maxSizeBytes, PhoenixConnection connection,
Map<TableRef, MultiRowMutationState> mutations, boolean subTask, PhoenixTransactionContext txContext) {
this.maxSize = maxSize;
this.maxSizeBytes = maxSizeBytes;
@@ -201,8 +204,8 @@ public class MutationState implements SQLCloseable {
}
}
- public MutationState(TableRef table, MultiRowMutationState mutations, long sizeOffset, long maxSize,
- long maxSizeBytes, PhoenixConnection connection) throws SQLException {
+ public MutationState(TableRef table, MultiRowMutationState mutations, long sizeOffset,
+ int maxSize, long maxSizeBytes, PhoenixConnection connection) throws SQLException {
this(maxSize, maxSizeBytes, connection, false, null, sizeOffset);
if (!mutations.isEmpty()) {
this.mutations.put(table, mutations);
@@ -216,7 +219,7 @@ public class MutationState implements SQLCloseable {
return estimatedSize;
}
- public long getMaxSize() {
+ public int getMaxSize() {
return maxSize;
}
@@ -368,7 +371,8 @@ public class MutationState implements SQLCloseable {
return false;
}
- public static MutationState emptyMutationState(long maxSize, long maxSizeBytes, PhoenixConnection connection) {
+ public static MutationState emptyMutationState(int maxSize, long maxSizeBytes,
+ PhoenixConnection connection) {
MutationState state = new MutationState(maxSize, maxSizeBytes, connection,
Collections.<TableRef, MultiRowMutationState> emptyMap(), false, null);
state.sizeOffset = 0;
@@ -377,13 +381,14 @@ public class MutationState implements SQLCloseable {
private void throwIfTooBig() throws SQLException {
if (numRows > maxSize) {
+ int mutationSize = numRows;
resetState();
- throw new SQLExceptionInfo.Builder(SQLExceptionCode.MAX_MUTATION_SIZE_EXCEEDED).build().buildException();
+ throw new MaxMutationSizeExceededException(maxSize, mutationSize);
}
if (estimatedSize > maxSizeBytes) {
+ long mutationSizeByte = estimatedSize;
resetState();
- throw new SQLExceptionInfo.Builder(SQLExceptionCode.MAX_MUTATION_SIZE_BYTES_EXCEEDED).build()
- .buildException();
+ throw new MaxMutationSizeBytesExceededException(maxSizeBytes, mutationSizeByte);
}
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MaxMutationSizeBytesExceededException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MaxMutationSizeBytesExceededException.java
new file mode 100644
index 0000000..95f25bd
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MaxMutationSizeBytesExceededException.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.schema;
+
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.exception.SQLExceptionInfo;
+import org.apache.phoenix.exception.SQLExceptionInfo.Builder;
+
+import java.sql.SQLException;
+
+/**
+ *
+ * Exception thrown when MutationState size is bigger than
+ * maximum allowed number of Bytes
+ *
+ */
+
+public class MaxMutationSizeBytesExceededException extends SQLException {
+
+ private static final long serialVersionUID = 1L;
+ private static SQLExceptionCode code = SQLExceptionCode.MAX_MUTATION_SIZE_BYTES_EXCEEDED;
+
+ public MaxMutationSizeBytesExceededException() {
+ super(new Builder(code).build().toString(), code.getSQLState(), code.getErrorCode(), null);
+ }
+
+ public MaxMutationSizeBytesExceededException(long maxMutationSizeBytes,
+ long mutationSizeBytes) {
+ super(new SQLExceptionInfo.Builder(code).setMaxMutationSizeBytes(maxMutationSizeBytes)
+ .setMutationSizeBytes(mutationSizeBytes).build().toString(),
+ code.getSQLState(), code.getErrorCode(), null);
+ }
+
+}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MaxMutationSizeExceededException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MaxMutationSizeExceededException.java
new file mode 100644
index 0000000..9fcf8c2
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MaxMutationSizeExceededException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.schema;
+
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.exception.SQLExceptionInfo;
+import java.sql.SQLException;
+
+/**
+ *
+ * Exception thrown when MutationState size is bigger than
+ * maximum allowed number of rows
+ *
+ */
+
+public class MaxMutationSizeExceededException extends SQLException {
+ private static final long serialVersionUID = 1L;
+ private static SQLExceptionCode code = SQLExceptionCode.MAX_MUTATION_SIZE_EXCEEDED;
+
+ public MaxMutationSizeExceededException() {
+ super(new SQLExceptionInfo.Builder(code).build().toString(), code.getSQLState(),
+ code.getErrorCode(), null);
+ }
+
+ public MaxMutationSizeExceededException(int maxMutationSize, int mutationSize) {
+ super(new SQLExceptionInfo.Builder(code).setMaxMutationSize(maxMutationSize)
+ .setMutationSize(mutationSize).build().toString(),
+ code.getSQLState(), code.getErrorCode(), null);
+ }
+}