You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]ApacheHttpClient5Transport enters unrecoverable state after IOReactorShutdownException #1969
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:
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.
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:
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>.
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.
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
Activity
mohityadav766 commentedon Apr 24, 2026
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:
We traced it to two independent triggers hitting the same HC5 failure mode:
Error(e.g.OutOfMemoryErrorduring response parsing) thrown on the selector thread. HC5'sAbstractSingleCoreIOReactor.execute()catchesExceptionseparately fromThrowable; the "any" branch forErrorcallsdoTerminate()+close(IMMEDIATE)+ rethrow, the worker dies, reactor transitions toSHUT_DOWN. HC5's defaultLoggingExceptionCallbackcan't intercept this because callbacks are typedCallback<Exception>.transport.close()on one of them.For (1), we applied an inline port of elastic/elasticsearch-java#1049's
SafeResponseConsumerpattern against opensearch-java'sApacheHttpClient5Options.setHttpAsyncResponseConsumerFactory(...)hook — wrap everyAsyncResponseConsumermethod withtry/catch (Throwable)and rethrowErrorasRuntimeException, 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 eachApacheHttpClient5Transportconstruction site) if a maintainer indicates the direction — open questions: (a) should this be opt-in or on by default, (b) should it live inopensearch-javareta commentedon Apr 27, 2026
@mohityadav766 please go ahead, the contribution will be highly appreciated, thank you