You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Desmond Yeung (JIRA)" <ji...@apache.org> on 2018/10/23 18:14:00 UTC
[jira] [Comment Edited] (HTTPCORE-560) LaxConnPool adds wrong
PoolEntry to leased when processing pending requests
[ https://issues.apache.org/jira/browse/HTTPCORE-560?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16661081#comment-16661081 ]
Desmond Yeung edited comment on HTTPCORE-560 at 10/23/18 6:13 PM:
------------------------------------------------------------------
Here's another stacktrace with {{release}}:
{code:java}
java.lang.IllegalStateException: Pool entry already present in the set of leased entries
at org.apache.hc.core5.pool.LaxConnPool$PerRoutePool.addLeased(LaxConnPool.java:393)
at org.apache.hc.core5.pool.LaxConnPool$PerRoutePool.release(LaxConnPool.java:474)
at org.apache.hc.core5.pool.LaxConnPool.release(LaxConnPool.java:162)
at org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager.release(PoolingAsyncClientConnectionManager.java:318)
at org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime.releaseConnection(InternalHttpAsyncExecRuntime.java:141)
at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1$2.completed(InternalAbstractHttpAsyncClient.java:268)
at org.apache.hc.client5.http.impl.async.AsyncProtocolExec$1.completed(AsyncProtocolExec.java:230)
at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.streamEnd(HttpAsyncMainClientExec.java:215)
at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler.dataEnd(ClientHttp1StreamHandler.java:272)
at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer.dataEnd(ClientHttp1StreamDuplexer.java:377)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onInput(AbstractHttp1StreamDuplexer.java:334)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.inputReady(AbstractHttp1IOEventHandler.java:62)
at org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler.inputReady(ClientHttp1IOEventHandler.java:38)
at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:117)
at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:50)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:173)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:123)
at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:80)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
at java.lang.Thread.run(Thread.java:748)
{code}
I can submit a patch if the suggested change looks correct.
was (Author: desmondyeung):
Here's another stacktrace with {{release}}:
{code:java}
java.lang.IllegalStateException: Pool entry already present in the set of leased entries
at org.apache.hc.core5.pool.LaxConnPool$PerRoutePool.addLeased(LaxConnPool.java:393)
at org.apache.hc.core5.pool.LaxConnPool$PerRoutePool.release(LaxConnPool.java:474)
at org.apache.hc.core5.pool.LaxConnPool.release(LaxConnPool.java:162)
at org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager.release(PoolingAsyncClientConnectionManager.java:318)
at org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime.releaseConnection(InternalHttpAsyncExecRuntime.java:141)
at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1$2.completed(InternalAbstractHttpAsyncClient.java:268)
at org.apache.hc.client5.http.impl.async.AsyncProtocolExec$1.completed(AsyncProtocolExec.java:230)
at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.streamEnd(HttpAsyncMainClientExec.java:215)
at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler.dataEnd(ClientHttp1StreamHandler.java:272)
at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer.dataEnd(ClientHttp1StreamDuplexer.java:377)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onInput(AbstractHttp1StreamDuplexer.java:334)
at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.inputReady(AbstractHttp1IOEventHandler.java:62)
at org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler.inputReady(ClientHttp1IOEventHandler.java:38)
at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:117)
at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:50)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:173)
at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:123)
at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:80)
at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
at java.lang.Thread.run(Thread.java:748)
{code}
> LaxConnPool adds wrong PoolEntry to leased when processing pending requests
> ---------------------------------------------------------------------------
>
> Key: HTTPCORE-560
> URL: https://issues.apache.org/jira/browse/HTTPCORE-560
> Project: HttpComponents HttpCore
> Issue Type: Bug
> Components: HttpCore
> Affects Versions: 5.0-beta5
> Reporter: Desmond Yeung
> Priority: Major
>
> I'm currently using HttpClient 5.0-beta1/HttpCore 5.0-beta2 and run into the following stacktrace fairly often in a production environment:
> {code:java}
> java.lang.IllegalStateException: Pool entry already present in the set of leased entries at org.apache.hc.core5.pool.LaxConnPool$PerRoutePool.addLeased(LaxConnPool.java:393) at org.apache.hc.core5.pool.LaxConnPool$PerRoutePool.lease(LaxConnPool.java:429) at org.apache.hc.core5.pool.LaxConnPool.lease(LaxConnPool.java:143) at org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager.lease(PoolingAsyncClientConnectionManager.java:216) at org.apache.hc.client5.http.impl.async.InternalHttpAsyncExecRuntime.acquireConnection(InternalHttpAsyncExecRuntime.java:89) at org.apache.hc.client5.http.impl.async.AsyncConnectExec.execute(AsyncConnectExec.java:152) at org.apache.hc.client5.http.impl.async.AsyncExecChainElement.execute(AsyncExecChainElement.java:54) at org.apache.hc.client5.http.impl.async.AsyncExecChainElement$1.proceed(AsyncExecChainElement.java:62) at org.apache.hc.client5.http.impl.async.AsyncProtocolExec.internalExecute(AsyncProtocolExec.java:170) at org.apache.hc.client5.http.impl.async.AsyncProtocolExec.execute(AsyncProtocolExec.java:133) at org.apache.hc.client5.http.impl.async.AsyncExecChainElement.execute(AsyncExecChainElement.java:54) at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1.sendRequest(InternalAbstractHttpAsyncClient.java:170) at org.apache.hc.core5.http.nio.BasicRequestProducer.sendRequest(BasicRequestProducer.java:65) at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient.execute(InternalAbstractHttpAsyncClient.java:144) at org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient.execute(CloseableHttpAsyncClient.java:78)
> {code}
> After doing some digging I believe that {{addLeased(releasedEntry);}} should be replaced with {{addLeased(availableEntry);}} in the following snippet of {{PerRoutePool#release}}. In it's current state, it appears that the polled {{leaseRequest}} gets leaked when this happens. Please let me know if my findings are correct.
>
> {code:java}
> while ((leaseRequest = pending.poll()) != null) {
> if (leaseRequest.isDone()) {
> continue;
> }
> final Object state = leaseRequest.getState();
> final Deadline deadline = leaseRequest.getDeadline();
> if (deadline.isExpired()) {
> leaseRequest.failed(DeadlineTimeoutException.from(deadline));
> } else {
> final PoolEntry<T, C> availableEntry = getAvailableEntry(state);
> if (availableEntry != null) {
> addLeased(releasedEntry);
> leaseRequest.completed(availableEntry);
> } else if (leased.size() < max) {
> final PoolEntry<T, C> newEntry = new PoolEntry<>(route, timeToLive);
> addLeased(newEntry);
> leaseRequest.completed(newEntry);
> }
> break;
> }
> }
> {code}
>
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org