-
Notifications
You must be signed in to change notification settings - Fork 914
[netty-nio-client] Ensure in-use channels are not incorrectly closed #2883
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
Conversation
IdleConnectionReaperHandler and OldConnectionReaperHandler are responsible for closing idle/old channels, but only when they are not marked as "in use". NettyRequestExecutor is responsible for marking a channel as "in use" as part of its logic to prepare a channel for a request. However, in rare circumstances, it may be possible for a channel to reach its idle time in between being acquired from the pool and having the request initiated (especially when the channel is acquired from a thread outside the EventLoop). We can make this more resilient by more aggressively marking the channel as "in use" as part of the channel acquire logic. Previously, NettyRequestExecutor was responsible for setting IN_USE and HandlerRemovingChannelPool was responsible for clearing it. We can leverage Netty's ChannelPoolHandler interface to make this behavior more symmetrical, by using a single ChannelPoolHandler to both set/clear the flag, which is also guaranteed by Netty to be executed by the Channel's EventLoop. The ChannelPoolHandler interface can actually be used to simplify some of our other ChannelPool-wrapping classes (the ones that don't need to actually manipulate the pool control flow). So this commit also takes the opportunity to migrate the existing HandlerRemovingChannelPool to leverage this interface.
This approach looks good to me! |
@Bennett-Lynch @dagnir |
Hi @pkgonan. I am actively working on it as a top priority. It should be released by the end of this week. |
Kudos, SonarCloud Quality Gate passed! |
Change merged and will be part of the next release. Our internal testing shows that this change may reduce the occurrence of transient |
@Bennett-Lynch |
The new error rate is almost immeasurably low. I suspect any remaining errors are likely outside of the SDK's control. Additionally, with retries enabled on |
This change was released today as part of version |
Hello, I've upgraded from SDK 1 to SDK 2 (2.17.100) and started getting errors such as this:
The error looks a bit different from the one that I found from the ticket #1615 Do you think my issue is also related to this fix? Thanks. |
Hi, I have read this post and others like it and I notice that you never could check if the updates on aws-sdk-java-v2 worked to fix your bug. I am currently using version 2.10.41 and the error persists in this version. Did you find out how to fix this bug ? |
IdleConnectionReaperHandler
andOldConnectionReaperHandler
are responsible for closing idle/old channels, but only when they are not marked asIN_USE
.NettyRequestExecutor
is responsible for marking a channel asIN_USE
as part of its logic to prepare a channel for a request. However, in rare circumstances, it may be possible for a channel to reach its idle time in between being acquired from the pool and having the request initiated (especially when the channel is acquired from a thread outside theEventLoop
). We can make this more resilient by more aggressively marking the channel asIN_USE
as part of the channel acquire logic, and ensuring this is run before the channel's health is queried byHealthCheckedChannelPool
(which will acquire a new channel, if needed).Previously,
NettyRequestExecutor
was responsible for settingIN_USE
andHandlerRemovingChannelPool
was responsible for clearing it. This PR introduces a simpleChannelPoolListener
interface that allows implementing classes to register behavior based on channels being acquired/released (while also guaranteeing the listener callbacks are executed within the channel'sEventLoop
). We can leverage this interface to make theIN_USE
behavior more symmetrical, by using a singleChannelPoolListener
to both set/clear the flag. TheChannelPoolListener
interface can additionally be used to simplify some of our otherChannelPool
-wrapping classes (the ones that don't need to actually manipulate the pool control flow). So this commit also takes the opportunity to migrate the existingHandlerRemovingChannelPool
to leverage this interface.License