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

Đang mở Phù hợp với người mới
#11,515 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@amalsaidov đang làm issue này rồi.

Từ ngày 12/11/2026.

  • #11516 của @amalsaidov — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
networking

Hướng nghiên cứu

Đọc RemotingHelper.connect(SocketAddress, int) và so sánh cấu hình bộ đệm của nó với NettyRemotingClient và NettyRemotingServer. Kiểm tra các bài kiểm thử hiện có cho RemotingHelper và bổ sung kiểm thử với các thiết lập bộ đệm gửi và nhận riêng biệt; hoàn thành khi mỗi thiết lập được ánh xạ tới tùy chọn socket tương ứng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
22.7k
Fork
12k
Merge trung bình
3 ngày 18 giờ
Pull request đã merge (30 ngày)
17

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/rocketmq

Tất cả issue của apache/rocketmq

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.