-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronously close pools when closing AbstractChannelPoolMap #9857
Conversation
Motivation: In netty#9830 the get/remove/close methods implementation changed to avoid deadlocks on event loops. The change involved modifying the methods to close the managed ChannelPools asynchronously and return immediately. While this behavior might be fine for get/remove, it is changing what a user expects from a close() method and after returning from close() there might be still resources open. Modifications: This change is a follow-up for netty#9830 to preserve the synchronous behavior of the AbstractChannelPoolMap#close() method. Result: AbstractChannelPoolMap#close() returns once the managed pools have been closed.
Can one of the admins verify this patch? |
@normanmaurer after taking a look at #9603 I realized there might be users expecting ChannelPoolMap#close() to close the underlying pools before returning. Since this was a synchronous call before my change in #9830 I think it would be safer to keep it synchronous. The other thing is that it is now becoming a bit messy what is executed synchronously and what not in ChannelPoolMap, since the interface suggests all methods are synchronous (no Futures returned), but To avoid breaking changes we could leave ChannelPoolMap/AbstractChannelPoolMap fully synchronous as the current interface suggests and adding a new AsyncChannelPoolMap/AbstractAsyncChannelPoolMap interface/class that returns Futures from get/remove/close that users can use to wait on if they would like to. This could go in tandem with an AsyncCloseablePool or similar interface that would make the current SimpleChannelPool#closeAsync method a member that can be used in these new pool maps without instance checks and internal branches more consistently. Please let me know if you think this might be worth adding. Thanks. |
@netty-bot test this please |
@mihalyr so you are suggesting to revert your commit ? |
@normanmaurer sorry for the confusion, I think about two options:
If you are good with the commit in this pull request, that is option 1 above, I think it should work for both cases, fixes #8238 and keeps the close behaviour, although with some added code complexity, which in this small class might be ok. But in a new major version probably some redesign of the ChannelPoolMap interface might help clear things up. Edits: Fixed issue references. |
@mihalyr got it... lets merge this then. In the next major release all the pool stuff is gone. |
@mihalyr thanks |
Hi, guys! Seems, the problem is still exists.
If I move the call of close() method to another thread pool, everything is working fine. |
Hi @sherman, it's been a while since the last time I touched Netty, but if I remember correctly the issue that I fixed was about opening pools causing deadlocks because Now someone extended the SimpleChannelPool class with a Back to the Would it be possbile for you to implement |
Hi, @mihalyr! May be the decision to revert your changes in close() wasn't a best idea. Because, the semantics would changed, but it wouldn't follow to the deadlock. Again, thank you for helping! |
Motivation:
In #9830 the get/remove/close methods implementation changed to avoid
deadlocks on event loops. The change involved modifying the methods to
close the managed ChannelPools asynchronously and return immediately.
While this behavior might be fine for get/remove, it is changing what
a user expects from a close() method and after returning from close()
there might be still resources open.
Modifications:
This change is a follow-up for #9830 to preserve the synchronous
behavior of the AbstractChannelPoolMap#close() method.
Result:
AbstractChannelPoolMap#close() returns once the managed pools have
been closed.
Related commit a322add
Related issues #8238, #9603