HBASE-24401 Cell size limit check on append should consider 0 or less value to disable the check (#1742)
Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
parent
1be583f021
commit
006e4d5e46
|
@ -8265,14 +8265,14 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
break;
|
break;
|
||||||
default: throw new UnsupportedOperationException(op.toString());
|
default: throw new UnsupportedOperationException(op.toString());
|
||||||
}
|
}
|
||||||
int newCellSize = PrivateCellUtil.estimatedSerializedSizeOf(newCell);
|
if (this.maxCellSize > 0) {
|
||||||
if (newCellSize > this.maxCellSize) {
|
int newCellSize = PrivateCellUtil.estimatedSerializedSizeOf(newCell);
|
||||||
String msg = "Cell with size " + newCellSize + " exceeds limit of " + this.maxCellSize
|
if (newCellSize > this.maxCellSize) {
|
||||||
+ " bytes in region " + this;
|
String msg = "Cell with size " + newCellSize + " exceeds limit of " + this.maxCellSize
|
||||||
if (LOG.isDebugEnabled()) {
|
+ " bytes in region " + this;
|
||||||
LOG.debug(msg);
|
LOG.debug(msg);
|
||||||
|
throw new DoNotRetryIOException(msg);
|
||||||
}
|
}
|
||||||
throw new DoNotRetryIOException(msg);
|
|
||||||
}
|
}
|
||||||
cellPairs.add(new Pair<>(currentValue, newCell));
|
cellPairs.add(new Pair<>(currentValue, newCell));
|
||||||
// Add to results to get returned to the Client. If null, cilent does not want results.
|
// Add to results to get returned to the Client. If null, cilent does not want results.
|
||||||
|
|
|
@ -977,9 +977,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|
||||||
int size = PrivateCellUtil.estimatedSerializedSizeOf(cells.current());
|
int size = PrivateCellUtil.estimatedSerializedSizeOf(cells.current());
|
||||||
if (size > r.maxCellSize) {
|
if (size > r.maxCellSize) {
|
||||||
String msg = "Cell with size " + size + " exceeds limit of " + r.maxCellSize + " bytes";
|
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);
|
throw new DoNotRetryIOException(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2239,7 +2239,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCellSizeLimit() throws IOException {
|
public void testCellSizeLimit() throws IOException {
|
||||||
final TableName tableName = TableName.valueOf("testCellSizeLimit");
|
final TableName tableName = name.getTableName();
|
||||||
TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
|
TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
|
||||||
new TableDescriptorBuilder.ModifyableTableDescriptor(tableName)
|
new TableDescriptorBuilder.ModifyableTableDescriptor(tableName)
|
||||||
.setValue(HRegion.HBASE_MAX_CELL_SIZE_KEY, Integer.toString(10 * 1024));
|
.setValue(HRegion.HBASE_MAX_CELL_SIZE_KEY, Integer.toString(10 * 1024));
|
||||||
|
@ -2276,6 +2276,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
|
@Test
|
||||||
public void testDeleteSpecifiedVersionOfSpecifiedColumn() throws Exception {
|
public void testDeleteSpecifiedVersionOfSpecifiedColumn() throws Exception {
|
||||||
final TableName tableName = name.getTableName();
|
final TableName tableName = name.getTableName();
|
||||||
|
|
Loading…
Reference in New Issue