-
Notifications
You must be signed in to change notification settings - Fork 356
Stale check command for async connections #547
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
base: master
Are you sure you want to change the base?
Conversation
4f0eea7
to
e67636b
Compare
Do you have the corresponding client changes? I tried integrating this into I think there's might be a race condition here involving command execution and connection closure. I remember a few years ago there was an issue where enabling inactive connection validation would cause the client to hang by submitting a |
|
||
@Override | ||
public boolean cancel() { | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cancel the callback
callback.completed(false); | ||
} | ||
final ByteBuffer buffer = ByteBuffer.allocate(0); | ||
final int bytesRead = ioSession.channel().read(buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this read is actually redundant. Command
is modeled as a write event, and reads are processed before writes. So if the connection is closed, we'll already know by the time we get here, provided that we include the changes from #543.
The end result ends up being very similar to the "synchronization barrier" between the event loop and the connection pool that I was talking about in that PR. The internal race condition basically goes away as long as connection reuse is completed through the event loop, which then has a chance to update all the relevant bookkeeping with respect to whatever IO events are pending.
I made the following changes locally:
When I do all of this, the results are dramatic:
When I disable inactive connection validation, I get the same results I've been getting:
We're definitely on the right track. If I'm right about the IO in |
I think I was mistaken about this. The actual issue might have been the no-op implementation of |
@rschmitt The results looks encouraging. |
@rschmitt I will fix the problem with |
e67636b
to
f70f0fd
Compare
@rschmitt This change-set introduces a relatively cheap 'stale' connection check command that works with both HTTP/1.1 and H2 protocols and can be used instead of a more expensive Ping command.
Please take a look.