Description
Elasticsearch Version
6.4.3
Installed Plugins
No response
Java Version
1.8
OS Version
centos 7.0.0
Problem Description
RestClient client = RestClient.builder("a","b","c");
RestClient.performRequestAsync(....)
throws exception
java.lang.StackOverflowError: null at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:131) at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.failed(AbstractClientExchangeHandler.java:419) at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.connectionRequestFailed(AbstractClientExchangeHandler.java:335) at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.access$100(AbstractClientExchangeHandler.java:62) at org.apache.http.impl.nio.client.AbstractClientExchangeHandler$1.failed(AbstractClientExchangeHandler.java:378) at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:134) at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalPoolEntryCallback.failed(PoolingNHttpClientConnectionManager.java:504) at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:134) at org.apache.http.nio.pool.AbstractNIOConnPool.fireCallbacks(AbstractNIOConnPool.java:454) at org.apache.http.nio.pool.AbstractNIOConnPool.lease(AbstractNIOConnPool.java:286) at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.requestConnection(PoolingNHttpClientConnectionManager.java:266) at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.requestConnection(AbstractClientExchangeHandler.java:363) at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.start(DefaultClientExchangeHandlerImpl.java:125) at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:141) at org.apache.http.impl.nio.client.CloseableHttpAsyncClient.execute(CloseableHttpAsyncClient.java:68) at org.elasticsearch.client.RestClient.performRequestAsync(RestClient.java:300) at org.elasticsearch.client.RestClient.access$600(RestClient.java:84) at org.elasticsearch.client.RestClient$1.retryIfPossible(RestClient.java:350) at org.elasticsearch.client.RestClient$1.failed(RestClient.java:332) at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:134) at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.failed(AbstractClientExchangeHandler.java:419) at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.connectionRequestFailed(AbstractClientExchangeHandler.java:335) at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.access$100(AbstractClientExchangeHandler.java:62) at org.apache.http.impl.nio.client.AbstractClientExchangeHandler$1.failed(AbstractClientExchangeHandler.java:378) at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:134) at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalPoolEntryCallback.failed(PoolingNHttpClientConnectionManager.java:504) at org.apache.http.concurrent.BasicFuture.failed(BasicFuture.java:134) at org.apache.http.nio.pool.AbstractNIOConnPool.fireCallbacks(AbstractNIOConnPool.java:454) at org.apache.http.nio.pool.AbstractNIOConnPool.lease(AbstractNIOConnPool.java:286) at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.requestConnection(PoolingNHttpClientConnectionManager.java:266) at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.requestConnection(AbstractClientExchangeHandler.java:363) at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.start(DefaultClientExchangeHandlerImpl.java:125) . . .
Steps to Reproduce
I know what's going on with this problem。
You can set a very short spring.elasticsearch.rest.sources.request-config.connection-request-timeout eg 1ms,http MaxPerRoute set 1。And mock many requests。Problems will occur
Because asynchttpclient called the firecallback method and entered Elasticsearch
futurecallcack#failed。 Elasticsearch attempted a retry in this function. Once again, it will enter the firecallback method of asynchttpclient, which increases the depth of the stack. When there are many tasks in the compledRequests queue of asynchttpclient, it will ultimately lead to stackover flow
Sorry, I am not a native English speaker. I hope you can understand。You can take a look at the code related to Elasticsearch retry and HTTP firecallback