This PR is an attempt to address #638 where we noticed that EventLoopGroup#shutdownGracefully timeouts are not waiting for active connections but is closing all the EventExecutor right away. [1]
It's not an issue on the Netty side but an expected behaviour. [2]
Still, people using a shutdown-timeout would expect active connections to be finished before shutting down the server.
The proposition is to track all Channel on an ChannelGroup [3], and wait for them to be closed before shutting down the server. This use case is mentioned on the ChannelGroup Java documentation.
[x] : Track all Channel on channel-active for HTTP and TCP servers
[x] : Wait the ChannelGroup for at most the shutdown-timeout
[x] : Take into account the elasped time when calling EventLoopGroup#shutdownGracefully
[x] : Ensure it's backward compatible with public exposed functions
[x] : Deprecate shutdown-quiet-period (which hasn't been released)
[x] : Reformat the code
Open questions
~Shall we apply this behavior only when shutdown-timeout is explicitly set? And keep the current weird behavior?~
~Do we have to be backward compatible with raw-ring-handler and ring-handler? Having that when channel-group is bothering me...~
Let's keep the current behavior when shutdown-timeout is not explicitly set.
Description
This PR is an attempt to address #638 where we noticed that
EventLoopGroup#shutdownGracefully
timeouts are not waiting for active connections but is closing all theEventExecutor
right away. [1] It's not an issue on the Netty side but an expected behaviour. [2]Still, people using a
shutdown-timeout
would expect active connections to be finished before shutting down the server. The proposition is to track allChannel
on anChannelGroup
[3], and wait for them to be closed before shutting down the server. This use case is mentioned on theChannelGroup
Java documentation.channel-active
for HTTP and TCP serversChannelGroup
for at most theshutdown-timeout
elasped
time when callingEventLoopGroup#shutdownGracefully
shutdown-quiet-period
(which hasn't been released)Open questions
shutdown-timeout
is explicitly set? And keep the current weird behavior?~raw-ring-handler
andring-handler
? Having thatwhen channel-group
is bothering me...~Let's keep the current behavior when
shutdown-timeout
is not explicitly set.[1] : https://github.com/netty/netty/blob/4.1/transport-classes-epoll/src/main/java/io/netty/channel/epoll/EpollEventLoop.java#L420 [2] : https://github.com/netty/netty/pull/3706#issuecomment-1303066857 [3] : https://netty.io/4.0/api/io/netty/channel/group/ChannelGroup.html