You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Anurag Agarwal (Jira)" <ji...@apache.org> on 2019/11/21 14:05:00 UTC

[jira] [Comment Edited] (HTTPASYNC-155) I/O Reactor Shutdown issues due to race condition in AbstractClientExchangeHandler

    [ https://issues.apache.org/jira/browse/HTTPASYNC-155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16979299#comment-16979299 ] 

Anurag Agarwal edited comment on HTTPASYNC-155 at 11/21/19 2:04 PM:
--------------------------------------------------------------------

So I am not able to completely understand your last comment but from the solution above let me confirm one thing that the runtime exception thrown will actually not be handled by the failed method since in failed we are checking if the closed value is set to true or not. As I explained in the above scenario that the cancelled had already been called which will mark the closed as true, failed won't execute and the exception will not go anywhere and won't be handled as well by anything else, it will just be dissolved.

All the other cleaning up step might have already been done by the cancel step only.


was (Author: altaiezior):
So I am not able to completely understand your last comment but from the solution above let me confirm one thing that the runtime exception thrown will actually not be handled by the failed method since in failed we are checking if the closed value is set to true or not. As I explained in the above scenario that the cancelled had already been called which will mark the closed as true, failed won't execute and the exception will not go anywhere and won't be handled as well by anything else, it will just be dissolved.

> I/O Reactor Shutdown issues due to race condition in AbstractClientExchangeHandler
> ----------------------------------------------------------------------------------
>
>                 Key: HTTPASYNC-155
>                 URL: https://issues.apache.org/jira/browse/HTTPASYNC-155
>             Project: HttpComponents HttpAsyncClient
>          Issue Type: Bug
>            Reporter: Anurag Agarwal
>            Priority: Major
>
> {code:java}
> HTTP GET http://localhost:8080/AdExchange/healthcheck: 500  Output: Health check failed because I/O reactor status STOPPED
> Time: Fri Nov 15 15:52:38 UTC 2019
> org.apache.http.impl.conn.ConnectionShutdownException
> 	at org.apache.http.impl.nio.conn.CPoolProxy.getValidConnection(CPoolProxy.java:74)
> 	at org.apache.http.impl.nio.conn.CPoolProxy.getContext(CPoolProxy.java:219)
> 	at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.connectionAllocated(AbstractClientExchangeHandler.java:328)
> 	at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.access$000(AbstractClientExchangeHandler.java:62)
> 	at org.apache.http.impl.nio.client.AbstractClientExchangeHandler$1.completed(AbstractClientExchangeHandler.java:387)
> 	at org.apache.http.impl.nio.client.AbstractClientExchangeHandler$1.completed(AbstractClientExchangeHandler.java:383)
> 	at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:122)
> 	at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$1.completed(PoolingNHttpClientConnectionManager.java:306)
> 	at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$1.completed(PoolingNHttpClientConnectionManager.java:297)
> 	at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:122)
> 	at org.apache.http.nio.pool.RouteSpecificPool.completed(RouteSpecificPool.java:146)
> 	at org.apache.http.nio.pool.AbstractNIOConnPool.requestCompleted(AbstractNIOConnPool.java:563)
> 	at org.apache.http.nio.pool.AbstractNIOConnPool$InternalSessionRequestCallback.completed(AbstractNIOConnPool.java:883)
> 	at org.apache.http.impl.nio.reactor.SessionRequestImpl.completed(SessionRequestImpl.java:154)
> 	at org.apache.http.impl.nio.reactor.AbstractIOReactor.processNewChannels(AbstractIOReactor.java:426)
> 	at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:287)
> 	at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
> 	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591)
> 	at java.lang.Thread.run(Thread.java:748)
> {code}
> I am currently not able to identify the excat source of this issue. But somewhere I am getting a hint that before execution of line AbstractClientExchnageHandler:328 
> {noformat}
> final HttpContext context = managedConn.getContext();
> {noformat}
> Cancel is called which discards the connection and detach the pool entry from the proxy. It was difficult to come up with the exact source since there are many places from where dicard connection and release connection is being called. But since only after adding the cancel workflow such errors are coming up, I tried to take that road and it seems possible that the race condition can indeed happen.
> We can notice in that method just few lines above this line we are checking if the handler is closed or not but even that line may have passed after which the connection was actually closed. It was just closed before the execution of this line as the line just above this line still has entry or else NullPointerException would have come.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org