Skip to content

[ISSUE #11515] Fix swapped socket send/receive buffer config in RemotingHelper.connect - #11516

Open
amalsaidov wants to merge 1 commit into
apache:developfrom
amalsaidov:fix-remotinghelper-socket-buffer-swap
Open

amalsaidov wants to merge 1 commit into
apache:developfrom
amalsaidov:fix-remotinghelper-socket-buffer-swap

Conversation

@amalsaidov

Copy link
Copy Markdown

Which Issue(s) This PR Fixes

Fixes #11515

Brief Description

RemotingHelper.connect wired the socket buffer knobs to the wrong options: socketSndbufSize was applied with setReceiveBufferSize and socketRcvbufSize with setSendBufferSize. Every other place in the remoting module maps socketSndbufSize to SO_SNDBUF and socketRcvbufSize to SO_RCVBUF (see NettyRemotingClient and NettyRemotingServer), so these two were swapped.

The store HA replication clients (DefaultHAClient, AutoSwitchHAClient) connect through this method, so tuning the buffer sizes gave the replication sockets the opposite send/receive buffer from what was configured.

This PR sets the send buffer from socketSndbufSize and the receive buffer from socketRcvbufSize.

How Did You Test This Change?

Added RemotingHelperTest#testConnectAppliesSndAndRcvBufferToMatchingSocketOption. The OS clamps and scales requested buffer sizes, so the test opens two connections that differ only in socketSndbufSize and reads back the send buffer from both: the connection configured with the smaller send buffer must end up with the smaller send buffer. With the knobs swapped the send buffer follows socketRcvbufSize, which inverts the comparison and fails the test.

Verified the test fails before the change and passes after, with mvn -pl remoting -am test -Dtest=RemotingHelperTest.

AI-assisted; directed, reviewed and tested by the author (amalsaidov).

… RemotingHelper.connect

RemotingHelper.connect applied socketSndbufSize to the receive buffer and
socketRcvbufSize to the send buffer, the opposite of the mapping used
everywhere else in the remoting module (NettyRemotingClient and
NettyRemotingServer map socketSndbufSize to SO_SNDBUF and socketRcvbufSize to
SO_RCVBUF). The store HA clients connect through this method, so tuning the
buffer knobs swapped the send and receive buffer sizes on the replication
sockets.

Set the send buffer from socketSndbufSize and the receive buffer from
socketRcvbufSize, and add a test that opens two connections differing only in
socketSndbufSize and checks the resulting send buffer tracks it.
@lwclover

Copy link
Copy Markdown
Member

LGTM

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.79%. Comparing base (164322b) to head (253fba7).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11516      +/-   ##
=============================================
- Coverage      49.79%   49.79%   -0.01%     
+ Complexity     14407    14406       -1     
=============================================
  Files           1391     1391              
  Lines         103381   103381              
  Branches       13529    13529              
=============================================
- Hits           51477    51476       -1     
+ Misses         45686    45682       -4     
- Partials        6218     6223       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants