Maciej created HTTPCLIENT-2146:
----------------------------------

             Summary: Non-blocking client stuck in infinite loop
                 Key: HTTPCLIENT-2146
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2146
             Project: HttpComponents HttpClient
          Issue Type: Bug
    Affects Versions: 5.0.3
            Reporter: Maciej


Our service after running for weeks ended up with 100% CPU usage. In a thread 
dump we identified that the issue comes from the Apache HttpClient:
{code:java}
"httpclient-dispatch-1" #34 daemon prio=5 os_prio=0 cpu=2658604.25ms 
elapsed=3332.51s tid=0x00007f9438003000 nid=0x3d runnable  [0x00007f94370f8000] 
java.lang.Thread.State: RUNNABLE at 
sun.nio.ch.IOUtil.write([email protected]/IOUtil.java:74) at 
sun.nio.ch.IOUtil.write([email protected]/IOUtil.java:50) at 
sun.nio.ch.SocketChannelImpl.write([email protected]/SocketChannelImpl.java:466)
 at org.apache.hc.core5.reactor.IOSessionImpl.write(IOSessionImpl.java:198) at 
org.apache.hc.core5.reactor.ssl.SSLIOSession.sendEncryptedData(SSLIOSession.java:462)
 at 
org.apache.hc.core5.reactor.ssl.SSLIOSession.access$700(SSLIOSession.java:71) 
at 
org.apache.hc.core5.reactor.ssl.SSLIOSession$1.outputReady(SSLIOSession.java:186)
 at 
org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:133)
 at 
org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51)
 at 
org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:179)
 at 
org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:128)
 at 
org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:85)
 at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44) at 
java.lang.Thread.run([email protected]/Thread.java:829) Locked ownable 
synchronizers: <0x00000000c53d0150> (a 
java.util.concurrent.locks.ReentrantLock$NonfairSync) <0x00000000c540d118> (a 
java.util.concurrent.locks.ReentrantLock$NonfairSync)
{code}
We're using following configuration for the non-blocking client:
{code:java}
final PoolingAsyncClientConnectionManager connectionManager =
    PoolingAsyncClientConnectionManagerBuilder.create()
        .setPoolConcurrencyPolicy(PoolConcurrencyPolicy.LAX)
        .setConnectionTimeToLive(connectionTimeToLive)
        .setMaxConnTotal(30)
        .setMaxConnPerRoute(30)
        .build();

final CloseableHttpAsyncClient httpclient =
    HttpAsyncClients.custom()
        .setKeepAliveStrategy(DefaultConnectionKeepAliveStrategy.INSTANCE)
        .setConnectionManager(connectionManager)
        .setConnectionReuseStrategy(DefaultConnectionReuseStrategy.INSTANCE)
        .build();
{code}
This issue seems to be similar to 
https://issues.apache.org/jira/browse/HTTPCORE-605 although I am not sure if 
its the same. We're also not able to reproduce it, but we are confident it was 
related to network issues or the response sent from the server because the 
problem persisted after restarting the service.

Do you know if the underlying issue has been solved in any of the newer 
`httpcomponents-core` versions (5.0.3 or 5.1)? Or is there a known workaround 
to handle such scenario to avoid exhausting the CPU?



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to