Skip to content

Honor keep-alive configuration in the port-unification server - #16562

Merged
EarthChen merged 2 commits into
apache:3.3from
wozhenbang2004:fix/port-unification-keepalive
Oct 30, 2026
Merged

EarthChen merged 2 commits into
apache:3.3from
wozhenbang2004:fix/port-unification-keepalive

Conversation

@wozhenbang2004

Copy link
Copy Markdown
Contributor

What is the purpose of the change?

Related #16558.

NettyServer already honors the ProtocolConfig.keepAlive setting (keep.alive in the exported URL), but NettyPortUnificationServer ignores it. As a result, explicitly enabling TCP keep-alive has no effect on accepted connections on the port-unification / Triple server path.

This change applies the existing setting to ChannelOption.SO_KEEPALIVE on accepted child channels, preserving the existing default of false.

The regression test builds URL parameters through ProtocolConfig, opens real loopback connections, and checks the accepted sockets for unspecified, enabled, and disabled keep-alive settings. The enabled case fails on the original implementation.

This is a configuration-consistency fix, not a complete solution for half-open connections: it does not change operating-system keep-alive probe timings or introduce an application idle timeout.

Validation

  • Original implementation: 4 tests, 1 failure (true was ignored), 0 errors.
  • Patched implementation: 4 tests, 0 failures/errors.
  • Project Spotless checks pass.
  • A broader 15-test selection passed 13 tests; two existing connection tests were blocked by non-loopback network access in the execution environment. Both errors were reproduced on the unmodified base revision. The broader run used the existing Byte Buddy dependency as a startup agent because this environment does not support Mockito self-attachment.
mvn -pl dubbo-remoting/dubbo-remoting-netty4 -am \
  -Dtest=PortUnificationServerTest \
  -Dsurefire.failIfNoSpecifiedTests=false test

Checklist

  • Linked the related GitHub issue.
  • Described what changes, how, and why.
  • Added a regression test covering enabled, disabled, and default behavior.
  • GitHub Actions results pending.

…n in the port-unification server

Apply the existing keep.alive setting to accepted child channels, matching NettyServer and preserving the false default.

Related apache#16558.
Cover unspecified, enabled, and disabled ProtocolConfig.keepAlive values using real loopback connections and accepted socket options.
@codecov-commenter

codecov-commenter commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.98%. Comparing base (1afcdf7) to head (9fb76f3).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #16562      +/-   ##
============================================
+ Coverage     59.02%   60.98%   +1.96%     
- Complexity       15    11760   +11745     
============================================
  Files          1953     1953              
  Lines         89284    89286       +2     
  Branches      13477    13477              
============================================
+ Hits          52700    54452    +1752     
+ Misses        30877    29249    -1628     
+ Partials       5707     5585     -122     
Flag Coverage Δ
integration-tests-java21 32.14% <100.00%> (?)
integration-tests-java8 32.31% <100.00%> (?)
samples-tests-java21 32.13% <0.00%> (?)
samples-tests-java8 29.77% <0.00%> (?)
unit-tests-java11 59.19% <100.00%> (-0.02%) ⬇️
unit-tests-java17 58.68% <100.00%> (+0.01%) ⬆️
unit-tests-java21 58.68% <100.00%> (-0.01%) ⬇️
unit-tests-java25 58.65% <100.00%> (-0.02%) ⬇️
unit-tests-java8 59.26% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@EarthChen EarthChen left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I reverted only the source change to base 1afcdf7883 and ran PortUnificationServerTest: the keepAlive=true case fails (expected: <true> but was: <false>). On the PR head all 4 cases pass. The change matches how NettyServer sets SO_KEEPALIVE, and the default stays false, so only users who explicitly set keep.alive=true see a behavior change.

One note: this PR does not fix the half-open connection problem in #16558. On Linux the default keepalive probe starts only after 7200 seconds, so that issue still needs a separate discussion about heartbeat / idle timeout.

@EarthChen
EarthChen merged commit 9465fc9 into apache:3.3 Oct 30, 2026
32 checks passed
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.

3 participants