Skip to content

Commit 08ed220

Browse files
committed
HBASE-26170 handleTooBigRequest in NettyRpcServer didn't skip enough bytes
1 parent 2e9ab3c commit 08ed220

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcFrameDecoder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
8787
NettyRpcServer.LOG.warn(requestTooBigMessage);
8888

8989
if (connection.connectionHeaderRead) {
90-
in.skipBytes(FRAME_LENGTH_FIELD_LENGTH);
9190
handleTooBigRequest(in);
9291
return;
9392
}
@@ -107,6 +106,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
107106
}
108107

109108
private void handleTooBigRequest(ByteBuf in) throws IOException {
109+
in.skipBytes(FRAME_LENGTH_FIELD_LENGTH);
110110
in.markReaderIndex();
111111
int preIndex = in.readerIndex();
112112
int headerSize = readRawVarint32(in);
@@ -118,6 +118,7 @@ private void handleTooBigRequest(ByteBuf in) throws IOException {
118118
}
119119

120120
if (in.readableBytes() < headerSize) {
121+
NettyRpcServer.LOG.debug("headerSize is larger than readableBytes");
121122
in.resetReaderIndex();
122123
return;
123124
}

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*/
1818
package org.apache.hadoop.hbase.client;
1919

20+
import static org.apache.hadoop.hbase.ipc.RpcServer.MAX_REQUEST_SIZE;
2021
import static org.junit.Assert.assertTrue;
21-
2222
import org.apache.hadoop.hbase.HBaseClassTestRule;
2323
import org.apache.hadoop.hbase.HBaseTestingUtil;
2424
import org.apache.hadoop.hbase.TableName;
@@ -48,6 +48,7 @@ public class TestRequestTooBigException {
4848

4949
@BeforeClass
5050
public static void setUpBeforeClass() throws Exception {
51+
TEST_UTIL.getConfiguration().setInt(MAX_REQUEST_SIZE, 10000);
5152
TEST_UTIL.startMiniCluster();
5253
}
5354

@@ -64,17 +65,18 @@ public void testHbasePutDeleteCell() throws Exception {
6465
TEST_UTIL.waitTableAvailable(tableName.getName(), 5000);
6566
try {
6667
byte[] value = new byte[2 * 2014 * 1024];
67-
68-
Put p = new Put(Bytes.toBytes("bigrow"));
69-
// big request = 400*2 M
70-
for (int i = 0; i < 400; i++) {
71-
p.addColumn(family, Bytes.toBytes("someQualifier" + i), value);
72-
}
73-
try {
74-
table.put(p);
75-
assertTrue("expected RequestTooBigException", false);
76-
} catch (RequestTooBigException e) {
77-
assertTrue("expected RequestTooBigException", true);
68+
for (int m = 0; m < 10000; m++) {
69+
Put p = new Put(Bytes.toBytes("bigrow"));
70+
// big request = 400*2 M
71+
for (int i = 0; i < 400; i++) {
72+
p.addColumn(family, Bytes.toBytes("someQualifier" + i), value);
73+
}
74+
try {
75+
table.put(p);
76+
assertTrue("expected RequestTooBigException", false);
77+
} catch (RequestTooBigException e) {
78+
assertTrue("expected RequestTooBigException", true);
79+
}
7880
}
7981
} finally {
8082
table.close();

0 commit comments

Comments
 (0)