This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.4 by this push:
new 25cf86e028b HBASE-27273 Should stop autoRead and skip all the bytes
when rpc request too big (#4679)
25cf86e028b is described below
commit 25cf86e028b2cfb4707c9ac7a43a758e4e997f82
Author: Duo Zhang <[email protected]>
AuthorDate: Sat Aug 6 20:08:07 2022 +0800
HBASE-27273 Should stop autoRead and skip all the bytes when rpc request
too big (#4679)
Signed-off-by: Xiaolin Ha <[email protected]>
(cherry picked from commit 486d19e99ff4370bc60e0db235508198c84a00e3)
---
.../org/apache/hadoop/hbase/ipc/NettyRpcFrameDecoder.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcFrameDecoder.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcFrameDecoder.java
index 164934ac247..dec00424e73 100644
---
a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcFrameDecoder.java
+++
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcFrameDecoder.java
@@ -44,6 +44,7 @@ public class NettyRpcFrameDecoder extends
ByteToMessageDecoder {
private final int maxFrameLength;
private boolean requestTooBig;
+ private boolean requestTooBigSent;
private String requestTooBigMessage;
public NettyRpcFrameDecoder(int maxFrameLength) {
@@ -58,8 +59,12 @@ public class NettyRpcFrameDecoder extends
ByteToMessageDecoder {
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object>
out) throws Exception {
+ if (requestTooBigSent) {
+ in.skipBytes(in.readableBytes());
+ return;
+ }
if (requestTooBig) {
- handleTooBigRequest(in);
+ handleTooBigRequest(ctx, in);
return;
}
@@ -83,7 +88,7 @@ public class NettyRpcFrameDecoder extends
ByteToMessageDecoder {
NettyRpcServer.LOG.warn(requestTooBigMessage);
if (connection.connectionHeaderRead) {
- handleTooBigRequest(in);
+ handleTooBigRequest(ctx, in);
return;
}
ctx.channel().close();
@@ -101,7 +106,7 @@ public class NettyRpcFrameDecoder extends
ByteToMessageDecoder {
out.add(in.readRetainedSlice(frameLengthInt));
}
- private void handleTooBigRequest(ByteBuf in) throws IOException {
+ private void handleTooBigRequest(ChannelHandlerContext ctx, ByteBuf in)
throws IOException {
in.skipBytes(FRAME_LENGTH_FIELD_LENGTH);
in.markReaderIndex();
int preIndex = in.readerIndex();
@@ -146,6 +151,10 @@ public class NettyRpcFrameDecoder extends
ByteToMessageDecoder {
// instead of calling reqTooBig.sendResponseIfReady()
reqTooBig.param = null;
connection.channel.writeAndFlush(reqTooBig).addListener(ChannelFutureListener.CLOSE);
+ in.skipBytes(in.readableBytes());
+ requestTooBigSent = true;
+ // disable auto read as we do not care newer data from this channel any
more
+ ctx.channel().config().setAutoRead(false);
}
private RPCProtos.RequestHeader getHeader(ByteBuf in, int headerSize) throws
IOException {