[ISSUE #11151] Coordinate graceful shutdown of remoting sub-servers - #11152
[ISSUE #11151] Coordinate graceful shutdown of remoting sub-servers#11152qianye1001 wants to merge 3 commits into
Conversation
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR coordinates graceful shutdown of remoting sub-servers so that parent and child shutdown grace periods overlap instead of accumulating sequentially. The implementation uses CompletableFuture for concurrent shutdown tracking and a ReentrantLock for state transitions only — waiting and channel closure happen outside the lock. Well-structured with comprehensive test coverage (270 lines of tests covering edge cases like pre-existing deadlines, disabled graceful shutdown, older client versions, and interruption).
LGTM — clean concurrency design, good test coverage, and the PR description clearly explains the rationale.
Automated review by github-manager-bot
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #11152 +/- ##
=============================================
- Coverage 49.39% 49.34% -0.05%
+ Complexity 14237 14227 -10
=============================================
Files 1390 1390
Lines 103122 103157 +35
Branches 13484 13494 +10
=============================================
- Hits 50932 50902 -30
- Misses 46029 46079 +50
- Partials 6161 6176 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR coordinates graceful shutdown across the parent NettyRemotingServer and its SubRemotingServer instances. The refactor replaces the sequential drain-and-close pattern with a concurrent approach: all sub-servers begin draining in parallel, the parent waits for the latest deadline, then closes listeners and releases shared resources.
The design is solid — AtomicBoolean guards ensure idempotent shutdown, AtomicReference<Long> for the deadline allows either caller (parent or child) to set it first, and interruption handling correctly preserves the interrupt flag. The 6 test methods comprehensively cover concurrent shutdown, disabled graceful mode, interrupted threads, and child-before-parent ordering.
LGTM.
Automated review by "github-manager-bot"
RockteMQ-AI
left a comment
There was a problem hiding this comment.
LGTM. Well-designed coordination of graceful shutdown across parent and sub-servers. The atomic state management correctly handles concurrent shutdown scenarios, and the deadline overlap logic avoids sequential accumulation. Comprehensive test coverage including edge cases (pre-existing child deadline, disabled graceful shutdown, interruption handling).
Automated review by github-manager-bot
Which Issue(s) This PR Fixes
Fixes #11151.
Brief Description
A sub-server now honors the existing graceful-shutdown configuration: it enters the draining state, keeps its listener open for its own grace period, and then closes that listener. Requests continue to use the existing
GO_AWAYhandling and client-version condition. Other ports and shared executors remain available when a child shuts down independently.Parent shutdown starts draining all children before waiting. Each server records its own deadline on its first transition to draining; an already draining child retains its original deadline. The parent waits for the latest deadline before closing child listeners and releasing shared resources, so the grace periods overlap instead of accumulating sequentially. An atomic compare-and-set records each child's first deadline, including when main and child shutdown run concurrently. Repeated shutdown calls return immediately without repeating cleanup or resetting the deadline. Coordination uses only atomic state and adds no executor or timer thread.
How Did You Test This Change?
jacoco.skip=true,spotbugs.skip=true; static analysis was run under JDK 11).CI test stabilization
TlsTest.disabledServerRejectsSSLClientaccepts either connection or send failure: the server rejects TLS by closing the connection, which may happen before the client checks channel activity or during its write. TLS tests use the loopback IP to avoid hostname resolution.TimerMessageStoreTest.testTimerFlowControlwaits for each accepted message to reach the timer wheel before testing the next admission, replacing a fixed 5 ms sleep. This preserves the flow-control assertions without assuming the asynchronous reput/enqueue work has already completed.