-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[improve][broker] Reduce the broker close time to avoid useless wait for event loop shutdown#24895
[improve][broker] Reduce the broker close time to avoid useless wait for event loop shutdown#24895lhotari merged 7 commits intoapache:masterfrom
Conversation
Fixes #24894
Motivation
Currently the quietPeriod parameter in Netty graceful shutdown in milliseconds is determined by the minimal value of 5000 and brokerShutdownTimeoutMs / 4 (default: 15000), which is unnecessarily large and could wait for too long with no pending tasks in the executor.
Modifications
- Modified the
quietPeriodargument as a small value (1 ms) - Added
BrokerEventLoopShutdownTestto avoid the regression - Added logs for how long that each event loop's gracefully shutdown takes.
It should be noted that setting 1 ms as the quietPeriod makes sense. It has been explained in #24894 (comment) and more details can be found in https://github.com/netty/netty/blob/6bb1a6bcae503423343b9155ac48b161f60368b5/common/src/main/java/io/netty/util/concurrent/SingleThreadEventExecutor.java
Here is the best practice suggested by AI:
Consider a very short quiet period if applicable: If your application is lightweight and you are certain no business logic is left to execute, you can use a very small value to terminate the event loop group immediately.
Verifying this change
After this change, the BrokerEventLoopShutdownTest can pass and the logs might look like:
2025-10-27T20:29:09,129 - INFO - [globalEventExecutor-9-2:BrokerService] - Event loop acceptor shut down after 104 ms
2025-10-27T20:29:09,130 - INFO - [globalEventExecutor-9-2:BrokerService] - Event loop worker shut down after 105 ms
Documentation
-
doc -
doc-required -
doc-not-needed -
doc-complete
Matching PR in forked repository
PR in forked repository:
|
There are multiple test failures with similar IllegalArgumentException: Error: Tests run: 4, Failures: 1, Errors: 0, Skipped: 2, Time elapsed: 23.36 s <<< FAILURE! -- in org.apache.pulsar.broker.loadbalance.SimpleBrokerStartTest |
|
Okay, let me take a look |
Codecov Report Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #24895 +/- ## ============================================= + Coverage 38.41% 74.27% +35.85% - Complexity 13133 33485 +20352 ============================================= Files 1856 1913 +57 Lines 145160 149331 +4171 Branches 16846 17334 +488 ============================================= + Hits 55760 110909 +55149 + Misses 81815 29580 -52235 - Partials 7585 8842 +1257
Flags with carried forward coverage won't be shown. Click here to find out more.
New features to boost your workflow:
|
(cherry picked from commit 411aea9)
(cherry picked from commit 61f6fcd)
(cherry picked from commit 411aea9)
(cherry picked from commit 61f6fcd)