[Bug] RemotingHelper.connect swaps the socket send and receive buffer configuration

オープン 初心者向け
#11,515 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@amalsaidov がすでに取り組んでいます。

2026年11月12日 から。

  • #11516 @amalsaidov による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
networking

調査の方向性

RemotingHelper.connect(SocketAddress, int)を読み、そのバッファ設定をNettyRemotingClientおよびNettyRemotingServerと比較してください。RemotingHelperの既存テストを確認し、送信バッファと受信バッファに異なる設定を使用したテストを追加してください。それぞれの設定が対応するソケットオプションに割り当てられれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Before Creating the 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.

主要言語
Java
スター
22.7k
フォーク
12k
平均マージ
3日 18時間
マージ済み PR(30日)
17

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/rocketmq のほかの issue

apache/rocketmq の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。