Skip to content

Frequent "I/O reactor terminated abnormally" crashes ES client (due to NoSuchElementException) #1003

Open
@LouisTrezzini

Description

@LouisTrezzini

Java API client version

7.17.28

Java version

java version "21.0.3" 2024-04-16 LTS

Elasticsearch Version

7.17.28

Problem description

Hello,

We are seeing frequent (about once per day) errors where the Apache HTTP client used by the Elasticsearch client stops working due to an I/O reactor terminated abnormally error.

Here is a full stack trace:

I/O dispatch worker terminated abnormally
    at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:359)
    at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
    at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
    at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by java.util.NoSuchElementException: null
    at java.base/java.util.Collections$1.next(Collections.java:5037)
    at co.elastic.clients.transport.rest_client.MultiBufferEntity.init(MultiBufferEntity.java:65)
    at co.elastic.clients.transport.rest_client.MultiBufferEntity.close(MultiBufferEntity.java:59)
    at org.apache.http.nio.protocol.BasicAsyncRequestProducer.close(BasicAsyncRequestProducer.java:155)
    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.releaseResources(DefaultClientExchangeHandlerImpl.java:84)
    at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.failed(AbstractClientExchangeHandler.java:429)
    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.exception(HttpAsyncRequestExecutor.java:163)
    at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:276)
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
    [8 more]

Impact:

  • When this happens, the HTTP client is marked as STOPPED.
  • As a result, all subsequent calls to the Elasticsearch client fail with:
 java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Request cannot be executed; I/O reactor status: STOPPED

Additional Context:

  • Apache HTTP versions:
org.apache.httpcomponents:httpasyncclient:4.1.4
org.apache.httpcomponents:httpclient:4.5.14
org.apache.httpcomponents:httpcore-nio:4.4.12
org.apache.httpcomponents:httpcore:4.4.16
  • We use BulkIngester quite heavily.
  • As a temporary workaround, we have a watchdog thread that checks if the HTTP client is still running and recreates the RestClient if needed. (Pseudocode below:)
if (!httpClient.isRunning()) {
    RestClient newClient = createClient();
    // Atomically swap httpClient, using an AtomicReference
}

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions