[Bug] RemotingHelper.connect swaps the socket send and receive buffer configuration
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- networking
Research direction
Read RemotingHelper.connect(SocketAddress, int) and compare its buffer configuration with NettyRemotingClient and NettyRemotingServer. Check the existing tests for RemotingHelper and add coverage using distinct send and receive buffer settings; done when each setting maps to its matching socket option.
Written by the indexing model from the issue text.
Description
Before Creating the Bug Report
- I searched the GitHub issues and found no similar bug report.
Runtime platform environment
All platforms.
RocketMQ version
develop branch (current), present in released versions as well.
Describe the Bug
RemotingHelper.connect(SocketAddress, int) applies the configured socket buffer sizes to the wrong socket options. The send-buffer knob (NettySystemConfig.socketSndbufSize) is used to set the receive buffer, and the receive-buffer knob (NettySystemConfig.socketRcvbufSize) is used to set the send buffer:
if (NettySystemConfig.socketSndbufSize > 0) {
sc.socket().setReceiveBufferSize(NettySystemConfig.socketSndbufSize);
}
if (NettySystemConfig.socketRcvbufSize > 0) {
sc.socket().setSendBufferSize(NettySystemConfig.socketRcvbufSize);
}
Everywhere else in the remoting module the mapping is the opposite one, e.g. in NettyRemotingClient and NettyRemotingServer:
socketSndbufSize->SO_SNDBUF(send buffer)socketRcvbufSize->SO_RCVBUF(receive buffer)
So in connect() the two are swapped.
This method is used by the store HA replication clients (DefaultHAClient and AutoSwitchHAClient). When an operator tunes com.rocketmq.remoting.socket.sndbuf.size / com.rocketmq.remoting.socket.rcvbuf.size, the HA sockets end up with the send and receive buffer sizes exchanged, which works against the intended replication tuning (the receive-heavy slave side and send-heavy master side get the opposite buffer they were configured for).
Expected Behavior
connect() should set SO_SNDBUF from socketSndbufSize and SO_RCVBUF from socketRcvbufSize, consistent with the rest of the remoting code.
Steps to Reproduce
Configure distinct values for the two knobs and open a connection through RemotingHelper.connect, then read back Socket#getSendBufferSize() / Socket#getReceiveBufferSize(): the reported send buffer tracks the receive-buffer configuration and vice versa.
How To Reproduce (code)
Open two connections that differ only in socketSndbufSize; the connection configured with the smaller send buffer ends up with the larger send buffer, because the value is taken from socketRcvbufSize.
- Dominant language
- Java
- Stars
- 22.7k
- Forks
- 12k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 17
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/rocketmq
-
CompressionType.of fails under the Turkish localePossibly taken @sharanggupta claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
[rocketmq-client-python] TransactionMQProducer allocates an unused producer during initializationOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
[Bug] notifyMasterOnline aborts the long-polling wake-up with a NullPointerException when an arrival drains a bucket firstPossibly taken @iloveeyjafjalla claimed this 29 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
apache/rocketmq#11441 · 1 comment ·
Maintainers usually reply within 1 day
-
[Enhancement] FilterFactory duplicate-registration and unregister semantics lack testsPossibly taken @chennaji9 claimed this 34 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/rocketmq#11340 · 2 comments ·
Maintainers usually reply within 1 day
-
[Enhancement] LogicExpression three-valued truth table and short-circuit behavior lack direct testsPossibly taken @chennaji9 claimed this 34 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/rocketmq#11339 · 2 comments ·
Maintainers usually reply within 1 day
Similar issues
-
bug emitter:client:csharp
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
microsoft/typespec#12572 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day
-
needs-area-label
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
area/ai area/backend component/zeebe kind/task
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
spAnser/reacharound#38 ·