-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Netty4SizeHeaderFrameDecoder error #31057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Netty4SizeHeaderFrameDecoder error #31057
Conversation
Pinging @elastic/es-core-infra |
final ByteBuf message = in.skipBytes(HEADER_SIZE); | ||
// 6 bytes would mean it is a ping. And we should ignore. | ||
if (messageLength != 6) { | ||
if (messageWithHeaderLength != 6) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is clearer if we just let TcpTransport.readMessageLength() return -1 in case of a ping (right now it returns 0, but TcpTransport.PING_DATA_SIZE itself is -1)
…...) in Netty4SizeHeaderFrameDecoder.
f20a2a2
to
e14a1cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a comment.
@@ -37,17 +37,17 @@ | |||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { | |||
try { | |||
BytesReference networkBytes = Netty4Utils.toBytesReference(in); | |||
int messageLength = TcpTransport.readMessageLength(networkBytes) + HEADER_SIZE; | |||
int messageLength = TcpTransport.readMessageLength(networkBytes); | |||
int messageWithHeaderLength = messageLength + HEADER_SIZE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not even think we should be making calculations with messageLength
if it is equal to -1
so we should guard all of this in if (messageLength != -1)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in: 6678992
int messageLength = TcpTransport.readMessageLength(networkBytes); | ||
// If the message length is -1, we have not read a complete header. | ||
if (messageLength != -1) { | ||
int messageWithHeaderLength = messageLength + HEADER_SIZE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably messageLengthWithHeader
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one more comment but this LGTM now. Good find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
retest this please |
1 similar comment
retest this please |
Always take into account return value of TcpTransport.readMessageLength(...) in Netty4SizeHeaderFrameDecoder.
If TcpTransport.readMessageLength(...) returned -1 then this was ignored because
HEADER_SIZE
was always added to what this method returns.During ccr benchmarking we have ran into the following error:
I'm not 100% sure whether that is caused by the fact the return value -1 was ignored, but after running the ccr benchmark many times with this change, I have not run into this error any more.