You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Maciej (Jira)" <ji...@apache.org> on 2021/04/06 09:18:00 UTC

[jira] [Created] (HTTPCLIENT-2146) Non-blocking client stuck in infinite loop

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(java.base@11.0.10/IOUtil.java:74) at sun.nio.ch.IOUtil.write(java.base@11.0.10/IOUtil.java:50) at sun.nio.ch.SocketChannelImpl.write(java.base@11.0.10/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(java.base@11.0.10/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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org