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

Aperta Adatta ai principianti
#11,515 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@amalsaidov ci sta già lavorando.

Dal 12/11/2026.

  • #11516 di @amalsaidov — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
networking

Direzione di ricerca

Leggi RemotingHelper.connect(SocketAddress, int) e confronta la sua configurazione dei buffer con quella di NettyRemotingClient e NettyRemotingServer. Controlla i test esistenti per RemotingHelper e aggiungi test con impostazioni distinte per i buffer di invio e ricezione; il lavoro è terminato quando ogni impostazione corrisponde alla relativa opzione del socket.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
22.7k
Fork
12k
Merge medio
3g 18h
PR unite (30g)
17

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/rocketmq

Tutte le issue di apache/rocketmq

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.