Skip to content
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

ZOOKEEPER-4907 Shouldn't throw "Len error" when server closing #2236

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jiafu1115
Copy link

Refer to ZOOKEEPER-4907

We got the error:

2024-11-07 19:03:01,414 [myid:14] - WARN [nioEventLoopGroup-7-25:NettyServerCnxn@537] - Closing connection to /135.224.186.250:47051
java.io.IOException: Len error 794913900
at org.apache.zookeeper.server.NettyServerCnxn.receiveMessage(NettyServerCnxn.java:521)
at org.apache.zookeeper.server.NettyServerCnxn.processMessage(NettyServerCnxn.java:374)
at org.apache.zookeeper.server.NettyServerCnxnFactory$CnxnChannelHandler.channelRead(NettyServerCnxnFactory.java:357)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead

It cause us very confused about it whether we write some big data into zookeeper. Thus. After trouble shooting, we found that it is just the log/issue when closing the server caused by reelecting the leader sometimes. In actually. We don't send any big data.

So I think we can do one tiny code change to avoid throw the error which causing confusion to reduce trouble shooting effort.

@jiafu1115
Copy link
Author

jiafu1115 commented Mar 17, 2025

The root cause for the error throw is caused by follow logic:
when closing the server. the follow code don't have chance to get executed:
bb = ByteBuffer.allocate(len); //line 552
so the remain message (body) will be taken as the head msg again and parsed again as the header.
then body length is not right now. sometimes it over the max size.
So I move the server status check before the length check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant