Nick Shanin created SOLR-18590:
----------------------------------
Summary: HttpJettySolrClient fails to close cleanly on an
already-interrupted thread
Key: SOLR-18590
URL: https://issues.apache.org/jira/browse/SOLR-18590
Project: Solr
Issue Type: Bug
Reporter: Nick Shanin
h2. Problem
Calling HttpJettySolrClient.close() with the caller's interrupt flag already set
can abort Jetty shutdown, leave an owned selector running, and consume the flag.
Confirmed on main at d298cd0b42602247bee7bf9e2bcf302e725f6690 with Jetty 12.1.14
and JDK 21.0.12.1+1 on Linux aarch64. No HTTP requests were needed.
h2. Reproduction
# Build a fresh HttpJettySolrClient with a caller-supplied executor using
withExecutor(pool).
# Set Thread.currentThread().interrupt() immediately before client.close().
# Capture the outcome and resource state before caller-pool cleanup, then clean
up.
The original close throws:
{code:java}
java.lang.RuntimeException: Exception on closing client
Caused by: java.lang.InterruptedException
at java.util.concurrent.CountDownLatch.await(...)
at org.eclipse.jetty.io.ManagedSelector.doStop(ManagedSelector.java:139)
{code}
One of two saved raw NIO selectors remained open one second after close threw,
with a worker still in Jetty's selector loop. The HttpClient and connector were
FAILED, tracking remained, and the caller pool was usable. A noninterrupted
control closed both selectors and released tracking without shutting down the
caller pool. The internally owned executor case also failed, after about
60 seconds in the shutdown fallback.
h2. Expected behavior
Close should finish owned-resource cleanup and preserve the interrupt, while
leaving caller-owned executors and borrowed parent clients usable.
h2. Cause and proposed fix
ManagedSelector.doStop() throws at its interruptible wait before submitting
StopSelector. Solr wraps the exception and skips subsequent normal cleanup.
The candidate captures and clears the interrupt after the existing async drain,
performs normal cleanup, then restores the flag in finally after executor
cleanup.
The async drain and ownership guards remain unchanged.
Candidate branch:
https://github.com/nick-boss-tech/solr/tree/solr-teardown-interrupt-close-fix
h2. Validation
Two new regressions fail before the fix: owned client and supplied executor.
The borrowed-client test passes before and after and guards compatibility.
The host reported HttpJettySolrClientTest passing 53/53 at candidate head
8787c6605ad5a5d322e9bca253235cd73142f101.
h2. Scope
Interrupts arriving during stop are outside this fix.
🤖 I used AI assistance. 🤖
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]