Intermittent exception in index call

We are using Elasticsearch java, in a lambda function. The below log is in lambda
Apparently this exception is happening when you use the Elastic of other component and quickly trigger the lambda function. Any suggestions?

Request execution cancelled: java.lang.RuntimeException
java.lang.RuntimeException: Request execution cancelled
	at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:938)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:300)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:288)
	at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:153)
	at co.elastic.clients.elasticsearch.ElasticsearchClient.index(ElasticsearchClient.java:1067)
	at co.elastic.clients.elasticsearch.ElasticsearchClient.index(ElasticsearchClient.java:1084)
	...
Caused by: java.util.concurrent.CancellationException: Request execution cancelled
	at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.execute(CloseableHttpAsyncClientBase.java:114)
	at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:138)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:296)

Thanks in advance

I managed to solve this by myself. The problem was that I was opening a connection with Elastic Search and never closing it.

So actually was working only for the first time and when trigger for the second that I already had the connection opened this problem happened.

The solution in this case was making sure every connection with ES has been closed after using it.

1 Like

@Luiz_Basile
Getting similar exception. Can you explain and show some code snippet that how are you "closing the connection?"

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.