-
Notifications
You must be signed in to change notification settings - Fork 983
Pooling managers: offload connection disposal from the pool lock. #726
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
Pooling managers: offload connection disposal from the pool lock. #726
Conversation
|
@arturobernalg This functionality is necessary for the classic connection management only where connections can get blocked in the Please reduce the scope to |
067a831 to
14b0b39
Compare
Done |
httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/AsyncDisposalCallback.java
Outdated
Show resolved
Hide resolved
httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/OffLockDisposalCallback.java
Outdated
Show resolved
Hide resolved
5ce8a9b to
97a89e9
Compare
3f19818 to
1094717
Compare
| * delegating the actual close to {@link DefaultDisposalCallback}. | ||
| */ | ||
| @Internal | ||
| final class AsyncDisposalCallback<C extends SocketModalCloseable> |
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.
removed.
...nt5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
Outdated
Show resolved
Hide resolved
b59ab28 to
358ffcc
Compare
...nt5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java
Outdated
Show resolved
Hide resolved
| throw new ExecutionException(ex.getMessage(), ex); | ||
| } | ||
| } finally { | ||
| lock.unlock(); |
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.
@arturobernalg This is a lease lock., not a global pool lock. It is perfectly OK to call #drainDisposals inside the method, for instance, at line 395 (prior to final ManagedHttpClientConnection conn = poolEntry.getConnection();)
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.
@arturobernalg This is a lease lock., not a global pool lock. It is perfectly OK to call
#drainDisposalsinside the method, for instance, at line 395 (prior tofinal ManagedHttpClientConnection conn = poolEntry.getConnection();)
@ok2c drainDisposals() now runs inside LeaseRequest#get right before poolEntry.getConnection() (lease lock only), with the final safety drain retained; tests updated accordingly.
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.
@arturobernalg The chances of anything going wrong in the remaining code is super-slim. And if it did happen the queue would get drained by another call / thread. But I think one #drainDisposals call should be enough here. Pick one you prefer. I leave it up to you.
3067c67 to
a98dd51
Compare
6b8827d to
050b7d9
Compare
ok2c
left a comment
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.
@arturobernalg Now the big question is whether this approach is stable enough to be activated by default or shall we mark it experimental and make optional in 5.6 release series?
35be10e to
05042bc
Compare
@ok2c |
ok2c
left a comment
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.
@arturobernalg Looks good to me.
…EFUL, run IMMEDIATE inline Drain queue after lease/release/closeExpired/closeIdle to avoid holding the pool lock
05042bc to
16c9d81
Compare
Close sockets off the pool lock via an async disposer. Improves lease latency under eviction/state mismatch with slow close.Includes classic/async tests and default-disposer baseline.