ZOOKEEPER-5044: NettyServerCnxnFactory.shutdown must explicitly shut down DefaultEventExecutor#2421
Open
asdf2014 wants to merge 1 commit into
Open
ZOOKEEPER-5044: NettyServerCnxnFactory.shutdown must explicitly shut down DefaultEventExecutor#2421asdf2014 wants to merge 1 commit into
asdf2014 wants to merge 1 commit into
Conversation
…down DefaultEventExecutor NettyServerCnxnFactory backs its channel group with a dedicated DefaultEventExecutor created as an anonymous instance, so shutdown() cannot terminate it and its non-daemon thread survives every factory shutdown. Instead of adding lifecycle management for that executor, stop creating it: back the channel group with GlobalEventExecutor.INSTANCE, the executor the ChannelGroup javadoc recommends. Its single shared thread starts on demand and stops itself after one second of idleness, so there is nothing left to shut down. This introduces no new thread kind: the termination futures of the boss/worker EventLoopGroups are already notified on GlobalEventExecutor on every shutdown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See https://issues.apache.org/jira/browse/ZOOKEEPER-5044
NettyServerCnxnFactorybacks its channel group with a dedicatedDefaultEventExecutorcreated as an anonymous instance, soshutdown()cannot terminate it and its non-daemon thread (defaultEventExecutor-N-1) survives every factory shutdown.Instead of adding lifecycle management for that executor, this change stops creating it: the channel group is now backed by
GlobalEventExecutor.INSTANCE, the executor theChannelGroupjavadoc recommends. Its single shared thread starts on demand and stops itself after one second of idleness, so there is nothing left to shut down.Notes for reviewers:
EventLoopGroups are already notified onGlobalEventExecutoron every shutdown (SingleThreadEventExecutorregisters them there), so every factory shutdown already spins this thread up today.DefaultChannelGroupFuturelisteners. The only bulk operation onallChannelsin the codebase is theclose()insideshutdown()itself, so the shared executor receives one or two sub-millisecond notification tasks per shutdown.defaultEventExecutor-*survives: it fails on current master (thread leaked) and passes with this change. The test is not included on purpose — with this fix the dedicated executor no longer exists, so there is nothing left to assert against.