SOLR-18312: introduce dedicated thread pool executor for httpClientBu… - #4655
SOLR-18312: introduce dedicated thread pool executor for httpClientBu…#4655renatoh wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR (SOLR-18312) updates HttpJdkSolrClient to use a dedicated executor for the JDK HttpClient, aiming to prevent deadlocks when request bodies are streamed (producer) while the JDK client consumes them (consumer), particularly under HTTP/1.1 with concurrent requests.
Changes:
- Introduce a separate
httpClientExecutorthat is always owned and shut down byHttpJdkSolrClient, instead of reusing the request-body streaming executor. - Add a concurrency regression test that issues multiple concurrent
JsonQueryRequestcalls with large streamed bodies while forcing HTTP/1.1.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpJdkSolrClient.java | Adds a dedicated executor for the underlying JDK HttpClient and ensures it is shut down on close. |
| solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpJdkSolrClientTest.java | Adds a concurrent, streamed-body test intended to catch deadlocks under HTTP/1.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dsmiley
left a comment
There was a problem hiding this comment.
I think it'd be more natural for the builder/configured executor to be for the httpClient usage itself, just as the jetty one.
|
I pushed an improvement to defer the use of the executor for body thread pushing to only start when it's requested (by the supplier). Maybe in practice won't be notice but I like the code for it much better now. CC @serhiy-bzhezytskyy |
|
@dsmiley the deferral does more than tidy the code — it removes the leak by construction for one whole class of failure. I measured it with a counting executor on a refused connection: before Two things I checked while I was in here, both fine:
The one thing missing is a test for the new property. I have the one above if you want it, against this branch or as a follow-up. |
|
Thanks for the review Serhiy. |
|
@dsmiley I resolved all the Copilot remarks. As far as I can see everything has been resolved, or is there anything left before this PR can be merged? |
dsmiley
left a comment
There was a problem hiding this comment.
Also the change (that I introduced RE executor initialization) results in no enforced cap/limit on threads. I didn't check if there's one at the JDK HttpClient level. If there's no limit, then it's worth a major-changes-since adoc file note. We should probably have a bit of javadoc somewhere to communicate whatever limit may or may not exist so at least users know. If there's no limit, IMO it's fine. It's straight-forward for a user to enforce via a semaphore if they wish.
@dsmiley |
Maybe I wasn't clear in my last message but I meant to communicate that IMO the executor on the builder should be for HttpClient. It is before this PR; you changed it in this PR. I think you should please change it back. I don't think a user should need to customize the executor used for POST'ing. |
…tpClient and not for writing the request bodies
|
@dsmiley OK, now I got it. Next try;) |
| queue, | ||
| new SolrNamedThreadFactory(this.getClass().getSimpleName())); | ||
| ExecutorUtil.newMDCAwareCachedThreadPool( | ||
| new SolrNamedThreadFactory(this.getClass().getSimpleName() + "-http")); |
There was a problem hiding this comment.
I would prefer to restore the name; no "-http" suffix. The class is for HTTP! (i.e. it doesn't disambiguate). As this is the natural/default executor, I don't think it needs disambiguation.
|
|
||
| /** | ||
| * Executor used to stream (produce) request bodies into the pipe consumed by the JDK HttpClient. | ||
| * This is the "producer" side and may be supplied by the caller. |
There was a problem hiding this comment.
Oh? Where? FWIW I don't think we should add to the builder over this minor matter.
…in-solr-10.adoc Co-authored-by: David Smiley <dsmiley@apache.org>
see ticket https://issues.apache.org/jira/browse/SOLR-18312