[
https://issues.apache.org/jira/browse/HTTPCLIENT-2437?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18144857#comment-18144857
]
seongsu shin commented on HTTPCLIENT-2437:
------------------------------------------
The core side of this is in master now:
* apache/httpcomponents-core#735 - StrictConnPool#enumAvailable / #enumLeased
now call fireCallbacks(), so a lease request failed there is notified right away
* apache/httpcomponents-core#738 - LaxConnPool fails an expired lease request
even when it is queued behind a live one
Neither is released yet, 5.5-beta4 doesn't have them.
I re-ran the original scenario with client master (async client, pool of 1,
connectionRequestTimeout 1s, server that never answers, request B sent while A
holds the connection, waiting up to 8s for B):
||pool policy||closeExpired() every 200ms||core 5.5-beta4||core master||
|STRICT|no|still waiting|still waiting|
|STRICT|yes|still waiting|fails after ~1.1s|
|LAX|no|still waiting|still waiting|
|LAX|yes|fails after ~1.1s|fails after ~1.1s|
|OFFLOCK|no|fails after ~1.0s|fails after ~1.0s|
So with a watcher thread calling closeExpired() the timeout now works for all
three pools, and OFFLOCK enforces it on its own. Without the watcher STRICT and
LAX still wait, which matches what Oleg described as by design.
What's left here is the documentation part. I can add a note to the connection
management guide that STRICT/LAX need a periodic closeExpired() (or
evictExpiredConnections()) for connectionRequestTimeout to fire on an idle
pool, if that works for you.
> Async connectionRequestTimeout does not fire on an otherwise idle pool
> ----------------------------------------------------------------------
>
> Key: HTTPCLIENT-2437
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2437
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpClient (async), Site
> Affects Versions: 5.6.5
> Reporter: seongsu shin
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
> h2. Summary
> On the async client, {{connectionRequestTimeout}} does not seem to fire
> unless something else happens in the connection pool. A request waiting for a
> lease can wait much longer than the configured timeout.
> h2. How to reproduce
> # Set {{connectionRequestTimeout}} to 1s and limit the pool to a single
> connection.
> # Send request A to a server that never completes the response. It holds the
> only connection.
> # Send request B to the same route.
> h2. Observed
> Request B was still waiting after 10s.
> h2. Expected
> Request B fails with a connection request timeout after about 1s.
> h2. Analysis
> I could not find a caller of {{validatePendingRequests()}}. Pending lease
> requests seem to be expired only when the pool is touched by other activity,
> so an otherwise idle pool never expires them. Enforcing this may need a
> periodic task or watcher thread, but I'm not sure whether this is intended.
> h2. Notes
> Found while writing the timeouts section for HTTPCLIENT-2404
> (https://github.com/apache/httpcomponents-website/pull/48). Oleg Kalnichevski
> asked there for a JIRA.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]