SOLR-17433: Set default http request timeout to infinite#4626
SOLR-17433: Set default http request timeout to infinite#4626VishnuPriyaChandraSekar wants to merge 8 commits into
Conversation
* Set the default request timeout to infinite by setting it to zero. This helps streams to continue streaming until they exhaust the content. * Prevent passing over the request timeout to JDK's HttpClient if the request timeout is zero. This is because JDK expects no value to represent infinite request timeout. * Updated ConcurrentUpdateSolrClientTestBase.testSocketTimeoutOnCommit to explicitly set a request timeout. The test previously relied on the default 1 ms request timeout (from idle timeout) to trigger an HTTP client timeout. After the default timeout was changed to infinite, the client no longer timed out, causing the test's 10-second timeout to fail first. This change restores the intended test behavior by overriding the request timeout explicitly. * Updated HttpJdkSolrClientTest.testTimeout to explicitly set a request timeout. Previously, request timeout was based on idle timeout. After the infinite request timeout, the client no longer timed out. Fixed the test by overriding the request timeout explicitly * Updated LB2SolrClientTest.testTimeoutExceptionMarksServerAsZombie to explicitly set a request timeout as the default request timeout causes the client to wait infinitely.
These files are not "released" (not in the source or any other release anymore).
…apache#4512) Querying root (top-level) documents no longer requires the verbose existence-negation idiom: Before: fq=*:* -_nest_path_:* After: fq=_nest_path_:\/ NestPathField now extends StrField instead of SortableTextField/CustomAnalyzer. Lucene's query parser bypasses getFieldQuery() for "tokenized" field; switching to an untokenized StrField fixed it. It's also simpler. The field is now a bit more strict about misconfiguration that was previously allowed. It doesn't support stored=true anymore but it's not needed anyway.
| .withIdleTimeout(overrideIdleTimeoutMs, TimeUnit.MILLISECONDS) | ||
| // override the infinite request timeout with idle timeout to ensure idle requests times | ||
| // out. | ||
| .withRequestTimeout(overrideIdleTimeoutMs, TimeUnit.MILLISECONDS); |
There was a problem hiding this comment.
This should probably just be 0, infinite?
| // override the infinite request timeout with idle timeout to ensure idle requests | ||
| // times out. |
There was a problem hiding this comment.
something seems suspicious... the idle timeout should work if the request timeout is infinite. They are different things; idle refers to the longest period of not receiving any data at all from the server. The request timeout is an overall timeout for the entire request.
|
Strangely... it seems this PR/branch now has several individual commits copied from main branch. If you intended to resync this PR with main, you simply merge main into your feature branch. To remedy this, simply do that now. |
We already have testRequestTimeout(). Idle is unsupported; can't be tested.
dsmiley
left a comment
There was a problem hiding this comment.
I checked out the PR and made 2 minor changes (see commit messages for each). I was focused on the Jetty client at first, as it's the most important client.
Then I proceeded to look at the JDK side closer. Then I found this: https://stackoverflow.com/questions/64550136/how-to-set-socket-timeout-in-java-http-client#:~:text=The%20HttpClient%20lets%20you%20set,the%20reception%20of%20the%20body.
Wow... so it appears JDK doesn't actually implement a request timeout as defined by Jetty HttpClient & Apache HttpClient. The JDK's supposed request timeout is for when the headers have been returned. And there's no socket idle timeout support at all. If this is true (and it should be confirmed from additional authoritative sources!) then what we call the idle timeout would loosely map to the JDK's request timeout, albeit somewhat inferior. And supporting a real request timeout would need to be on top of the JDK HttpClient, thus in HttpJdkSolrClient.
We should ensure our builder javadocs are extra clear on these things so users understand what they are setting. We tried to be generic but JDK in particular will have a quirk with idle's definition.
| @@ -0,0 +1,7 @@ | |||
| title: Changed default http request timeout to infinite | |||
There was a problem hiding this comment.
| title: Changed default http request timeout to infinite | |
| title: > | |
| SolrClients no longer have a default request timeout. It was problematic with streaming expressions. | |
| The idle timeout remains, albeit the JDK HttpClient doesn't support that (has none). |
Description
In earlier versions of SolrJ 9.4, the legacy HttpSolrClient was able to support long running streaming operation (> 10 mins). However, in SolrJ 9.4+, the http client throws exception exactly after 10 mins.
https://issues.apache.org/jira/browse/SOLR-17433
Solution
In case of long streaming operation, the server sends the response in chunks and request timeout determines how long the client can wait to receive all the chunks. The default request timeout was set to 10 mins which caused the streaming operations to timeout abruptly.
In order to support long running streams, the request timeout must be infinite (as we don't know how long streams will take to complete). Jetty excepts either 0 or -1 however JDK expects no value to represent the infinite timeout. The following changes were made to implement the behavior
HttpSolrClient: Set the default request timeout to infinite by setting it to zero. This helps streams to continue streaming until they exhaust the content.HttpJdkSolrClient: Prevented passing over the request timeout to JDK's HttpClient if it is zero.Tests
ConcurrentUpdateSolrClientTestBase.testSocketTimeoutOnCommitto explicitly set a request timeout. The test previously relied on the default 1 ms request timeout (from idle timeout) to trigger an HTTP client timeout. After the default timeout was changed to infinite, the client no longer timed out, causing the test's 10-second timeout to fail first. This change restores the intended test behavior by overriding the request timeout explicitly.HttpJdkSolrClientTest.testTimeoutto explicitly set a request timeout. Previously, request timeout was based on idle timeout. After the infinite request timeout, the client no longer timed out. Fixed the test by overriding the request timeout explicitlyLB2SolrClientTest.testTimeoutExceptionMarksServerAsZombieto explicitly set a request timeout as the default value causes the client to wait infinitely.Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.