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

Abierto Apto para principiantes
#11,515 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@amalsaidov ya está trabajando en esto.

Desde el 12/11/2026.

  • #11516 de @amalsaidov — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
82/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
networking

Línea de trabajo

Lee RemotingHelper.connect(SocketAddress, int) y compara su configuración de búferes con la de NettyRemotingClient y NettyRemotingServer. Revisa las pruebas existentes para RemotingHelper y añade cobertura con configuraciones distintas para los búferes de envío y recepción; el trabajo estará terminado cuando cada configuración corresponda a su opción de socket.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Java
Estrellas
22.7k
Forks
12k
Merge medio
3 d 18 h
PR fusionados (30 d)
17

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/rocketmq

Todos los issues de apache/rocketmq

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.