You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zg...@apache.org on 2020/05/25 02:21:03 UTC
[hbase] 02/02: HBASE-24401 Cell size limit check on append should
consider 0 or less value to disable the check (#1742)
This is an automated email from the ASF dual-hosted git repository.
zghao pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
commit 03929770fe4f469a2754ee7b1178623773f800b2
Author: wenbang <81...@qq.com>
AuthorDate: Mon May 25 09:58:01 2020 +0800
HBASE-24401 Cell size limit check on append should consider 0 or less value to disable the check (#1742)
Signed-off-by: Guanghao Zhang <zg...@apache.org>
---
.../apache/hadoop/hbase/regionserver/HRegion.java | 12 +++++------
.../hadoop/hbase/regionserver/RSRpcServices.java | 4 +---
.../hadoop/hbase/client/TestFromClientSide5.java | 24 +++++++++++++++++++++-
3 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 2c50495..e5a9b37 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -8219,14 +8219,14 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
break;
default: throw new UnsupportedOperationException(op.toString());
}
- int newCellSize = PrivateCellUtil.estimatedSerializedSizeOf(newCell);
- if (newCellSize > this.maxCellSize) {
- String msg = "Cell with size " + newCellSize + " exceeds limit of " + this.maxCellSize
- + " bytes in region " + this;
- if (LOG.isDebugEnabled()) {
+ if (this.maxCellSize > 0) {
+ int newCellSize = PrivateCellUtil.estimatedSerializedSizeOf(newCell);
+ if (newCellSize > this.maxCellSize) {
+ String msg = "Cell with size " + newCellSize + " exceeds limit of " + this.maxCellSize
+ + " bytes in region " + this;
LOG.debug(msg);
+ throw new DoNotRetryIOException(msg);
}
- throw new DoNotRetryIOException(msg);
}
cellPairs.add(new Pair<>(currentValue, newCell));
// Add to results to get returned to the Client. If null, cilent does not want results.
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
index 4119e4f..8f57a37 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
@@ -973,9 +973,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
int size = PrivateCellUtil.estimatedSerializedSizeOf(cells.current());
if (size > r.maxCellSize) {
String msg = "Cell with size " + size + " exceeds limit of " + r.maxCellSize + " bytes";
- if (LOG.isDebugEnabled()) {
- LOG.debug(msg);
- }
+ LOG.debug(msg);
throw new DoNotRetryIOException(msg);
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide5.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide5.java
index cff4959..0ae15ca 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide5.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide5.java
@@ -2235,7 +2235,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
@Test
public void testCellSizeLimit() throws IOException {
- final TableName tableName = TableName.valueOf("testCellSizeLimit");
+ final TableName tableName = name.getTableName();
TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
new TableDescriptorBuilder.ModifyableTableDescriptor(tableName)
.setValue(HRegion.HBASE_MAX_CELL_SIZE_KEY, Integer.toString(10 * 1024));
@@ -2273,6 +2273,28 @@ public class TestFromClientSide5 extends FromClientSideBase {
}
@Test
+ public void testCellSizeNoLimit() throws IOException {
+ final TableName tableName = name.getTableName();
+ ColumnFamilyDescriptor familyDescriptor =
+ new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(FAMILY);
+ TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
+ new TableDescriptorBuilder.ModifyableTableDescriptor(tableName)
+ .setValue(HRegion.HBASE_MAX_CELL_SIZE_KEY, Integer.toString(0));
+ tableDescriptor.setColumnFamily(familyDescriptor);
+
+ try (Admin admin = TEST_UTIL.getAdmin()) {
+ admin.createTable(tableDescriptor);
+ }
+
+ // Will succeed
+ try (Table ht = TEST_UTIL.getConnection().getTable(tableName)) {
+ ht.put(new Put(ROW).addColumn(FAMILY, QUALIFIER, new byte[HRegion.DEFAULT_MAX_CELL_SIZE -
+ 1024]));
+ ht.append(new Append(ROW).addColumn(FAMILY, QUALIFIER, new byte[1024 + 1]));
+ }
+ }
+
+ @Test
public void testDeleteSpecifiedVersionOfSpecifiedColumn() throws Exception {
final TableName tableName = name.getTableName();