You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "qxo (Jira)" <ji...@apache.org> on 2023/02/27 05:12:00 UTC

[jira] [Commented] (HTTPCLIENT-1924) connection leak issue when OutOfMemory

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

qxo commented on HTTPCLIENT-1924:
---------------------------------

ca98ad69a 20180616_10:33 Oleg Kalnichevski HTTPCLIENT-1924: HttpClient to shut down the connection manager if a fatal error occurs in the course o... This commit should be reviewed, please! 

ref:  [https://github.com/apache/httpcomponents-client/commit/ca98ad69adad79de57d8b944ba524f7267a795cb#diff-0f014e19e7deac908eabc9d7ff104061731a3a0e87102c7d21b70092f8ad0cc3]

shutdown the connection manager is inappropriate and meaningless, the app is still unavailable anyway, and we have to restart the app!

 

 

 

> connection leak issue when OutOfMemory
> --------------------------------------
>
>                 Key: HTTPCLIENT-1924
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1924
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 4.5.3, 4.5.4, 4.5.5
>            Reporter: wenqi.huang
>            Priority: Major
>             Fix For: 4.5.6, 5.0 Beta2
>
>
> *Yesterday, I found one of our java app is continuously throwing the following exception:*
>  
> _org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool
>  at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.leaseConnection(PoolingHttpClientConnectionManager.java:313)
>  at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$1.get(PoolingHttpClientConnectionManager.java:279)
>  at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:191)
>  at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
>  at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
>  at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
>  at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
>  at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
>  at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)_
> _at ....._
>  
> *So I look into the log, I found that before this exception occurs, there are some `OutOfMemoryError`s (there are many different type of OutOfMemoryError, I just copy&paste the most interesting one):* 
>  
> _java.lang.OutOfMemoryError: GC overhead limit exceeded_
>  _at org.apache.http.util.CharArrayBuffer.substringTrimmed(CharArrayBuffer.java:466)_
>  _at org.apache.http.message.BasicLineParser.parseProtocolVersion(BasicLineParser.java:163)_
>  _at org.apache.http.message.BasicLineParser.parseStatusLine(BasicLineParser.java:366)_
>  _at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:158)_
>  _at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)_
>  _at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)_
>  _at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)_
>  _at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:165)_
>  _at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)_
>  _at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)_
>  _at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)_
>  _at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)_
>  _at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)_
>  _at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)_
>  _at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)_
>  _at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)_
>  _at ........_
>  _at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)_
>  _at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)_
>  at java.lang.Thread.run(Thread.java:745)
>  
> *I look into the source code of httpClient, and found that when the `OutOfMemoryError` is occur at the exacting place, the `HttpConnection` will never be get released, so it will leak, and never to be reused any more, so the following http call will be rejected,  that's why `Timeout waiting for connection from pool` is *continuously trigged, even after my system have been recovered from the `GC` problem, this problem will never auto back to normal. so at this point to resolve this problem, my only choice is to fully restart my system.** 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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