Skip to content

[BUG]ApacheHttpClient5Transport enters unrecoverable state after IOReactorShutdownException #1969

Open

Description

@karthikeyantuf

Description
We are encountering a persistent IOReactorShutdownException ("I/O reactor has been shut down") when using ApacheHttpClient5Transport.

Once the transport enters this state—typically triggered under high load or following an OOM event—all subsequent requests fail consistently. The client does not recover automatically, and the only workaround is to restart the process or manually recreate the client/transport.

This effectively puts the application into a permanently degraded state.

Context & Comparison
This behavior appears similar to an issue previously reported and addressed in the Elasticsearch Java client:

Issue: elastic/elasticsearch-java#1046
Fix/Mitigation: elastic/elasticsearch-java#1049

The fix there ensures the transport can recover instead of remaining in a failed state.

Expected Behavior
The OpenSearch Java Client should provide similar resilience, allowing the transport layer to recover from IOReactorShutdownException without requiring a full application restart or manual client reinitialization.

Current Environment

Library: OpenSearch Java Client
Version: 3.4.0
Transport: ApacheHttpClient5Transport 5.5.2

Activity

  1. added
    bug
    on Apr 21, 2026
  2. mohityadav766 commented on Apr 24, 2026

    @mohityadav766

    We hit this exact symptom in OpenMetadata (opensearch-java 3.4.0, HC5 transport, basic auth against AWS OpenSearch). Full exception chain we captured in production matched the one in the issue description verbatim:

    RuntimeException: I/O reactor has been shut down
      → IOReactorShutdownException: I/O reactor has been shut down
    

    We traced it to two independent triggers hitting the same HC5 failure mode:

    1. An Error (e.g. OutOfMemoryError during response parsing) thrown on the selector thread. HC5's AbstractSingleCoreIOReactor.execute() catches Exception separately from Throwable; the "any" branch for Error calls doTerminate() + close(IMMEDIATE) + rethrow, the worker dies, reactor transitions to SHUT_DOWN. HC5's default LoggingExceptionCallback can't intercept this because callbacks are typed Callback<Exception>.
    2. A caller that shares the transport across multiple components calling transport.close() on one of them.

    For (1), we applied an inline port of elastic/elasticsearch-java#1049's SafeResponseConsumer pattern against opensearch-java's ApacheHttpClient5Options.setHttpAsyncResponseConsumerFactory(...) hook — wrap every AsyncResponseConsumer method with try/catch (Throwable) and rethrow Error as RuntimeException, so HC5 routes it through the Exception path instead. Works end-to-end on our production payloads; reproduction test covers both the "without wrapper reactor dies" and "with wrapper reactor survives" sides of the A/B.

    Reference implementation + regression test: open-metadata/OpenMetadata#27698

    Happy to contribute the wrapper upstream (~130 lines added + one setOptions(...) call at each ApacheHttpClient5Transport construction site) if a maintainer indicates the direction — open questions: (a) should this be opt-in or on by default, (b) should it live in opensearch-java

  3. reta commented on Apr 27, 2026

    @reta
    Collaborator

    @mohityadav766 please go ahead, the contribution will be highly appreciated, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions