Skip to content

Commit 0392977

Browse files
wenbanginfraio
authored andcommitted
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>
1 parent 61eb7e5 commit 0392977

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8219,14 +8219,14 @@ private List<Cell> reckonDeltasByStore(HStore store, Operation op, Mutation muta
82198219
break;
82208220
default: throw new UnsupportedOperationException(op.toString());
82218221
}
8222-
int newCellSize = PrivateCellUtil.estimatedSerializedSizeOf(newCell);
8223-
if (newCellSize > this.maxCellSize) {
8224-
String msg = "Cell with size " + newCellSize + " exceeds limit of " + this.maxCellSize
8225-
+ " bytes in region " + this;
8226-
if (LOG.isDebugEnabled()) {
8222+
if (this.maxCellSize > 0) {
8223+
int newCellSize = PrivateCellUtil.estimatedSerializedSizeOf(newCell);
8224+
if (newCellSize > this.maxCellSize) {
8225+
String msg = "Cell with size " + newCellSize + " exceeds limit of " + this.maxCellSize
8226+
+ " bytes in region " + this;
82278227
LOG.debug(msg);
8228+
throw new DoNotRetryIOException(msg);
82288229
}
8229-
throw new DoNotRetryIOException(msg);
82308230
}
82318231
cellPairs.add(new Pair<>(currentValue, newCell));
82328232
// Add to results to get returned to the Client. If null, cilent does not want results.

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,9 +973,7 @@ private void checkCellSizeLimit(final HRegion r, final Mutation m) throws IOExce
973973
int size = PrivateCellUtil.estimatedSerializedSizeOf(cells.current());
974974
if (size > r.maxCellSize) {
975975
String msg = "Cell with size " + size + " exceeds limit of " + r.maxCellSize + " bytes";
976-
if (LOG.isDebugEnabled()) {
977-
LOG.debug(msg);
978-
}
976+
LOG.debug(msg);
979977
throw new DoNotRetryIOException(msg);
980978
}
981979
}

hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide5.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2235,7 +2235,7 @@ public void testFilterAllRecords() throws IOException {
22352235

22362236
@Test
22372237
public void testCellSizeLimit() throws IOException {
2238-
final TableName tableName = TableName.valueOf("testCellSizeLimit");
2238+
final TableName tableName = name.getTableName();
22392239
TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
22402240
new TableDescriptorBuilder.ModifyableTableDescriptor(tableName)
22412241
.setValue(HRegion.HBASE_MAX_CELL_SIZE_KEY, Integer.toString(10 * 1024));
@@ -2272,6 +2272,28 @@ public void testCellSizeLimit() throws IOException {
22722272
}
22732273
}
22742274

2275+
@Test
2276+
public void testCellSizeNoLimit() throws IOException {
2277+
final TableName tableName = name.getTableName();
2278+
ColumnFamilyDescriptor familyDescriptor =
2279+
new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(FAMILY);
2280+
TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
2281+
new TableDescriptorBuilder.ModifyableTableDescriptor(tableName)
2282+
.setValue(HRegion.HBASE_MAX_CELL_SIZE_KEY, Integer.toString(0));
2283+
tableDescriptor.setColumnFamily(familyDescriptor);
2284+
2285+
try (Admin admin = TEST_UTIL.getAdmin()) {
2286+
admin.createTable(tableDescriptor);
2287+
}
2288+
2289+
// Will succeed
2290+
try (Table ht = TEST_UTIL.getConnection().getTable(tableName)) {
2291+
ht.put(new Put(ROW).addColumn(FAMILY, QUALIFIER, new byte[HRegion.DEFAULT_MAX_CELL_SIZE -
2292+
1024]));
2293+
ht.append(new Append(ROW).addColumn(FAMILY, QUALIFIER, new byte[1024 + 1]));
2294+
}
2295+
}
2296+
22752297
@Test
22762298
public void testDeleteSpecifiedVersionOfSpecifiedColumn() throws Exception {
22772299
final TableName tableName = name.getTableName();

0 commit comments

Comments
 (0)