amalsaidov opened a new issue, #11515: URL: https://github.com/apache/rocketmq/issues/11515
### Before Creating the Bug Report - [X] I searched the [GitHub issues](https://github.com/apache/rocketmq/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: ```java 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`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
