Skip to content

SOLR-17776: Harmonize SolrJ timeouts #3357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ Improvements
* SOLR-16951: Add PKI Auth Caching for both generation of the PKI Auth Tokens and validation of received tokens.
The default PKI Auth validity TTL has been increased from 5 seconds to 10 seconds. (Houston Putman)

* SOLR-17776: SolrJ: If Http2SolrClient.Builder.withHttpClient is used, (and it's used more in 9.8, shifted from deprecated Apache HttpClient
based clients), settings affecting HttpClient construction cannot be customized; an IllegalStateException will now be thrown if you try.
The connection timeout cannot be customized, but idle & request timeouts can be. Callers (various places in Solr) no longer customize the connection timeout.
(David Smiley, Luke Kot-Zaniewski)

* SOLR-17776: The HttpJdkSolrClient wasn't setting the connection timeout as per the builder configuration. (David Smiley)

Optimizations
---------------------
* SOLR-17578: Remove ZkController internal core supplier, for slightly faster reconnection after Zookeeper session loss. (Pierre Salagnac)
Expand Down
1 change: 0 additions & 1 deletion solr/core/src/java/org/apache/solr/cloud/Overseer.java
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,6 @@ private void doCompatCheck(BiConsumer<String, Object> consumer) {
new Http2SolrClient.Builder()
.withHttpClient(getCoreContainer().getDefaultHttpSolrClient())
.withIdleTimeout(30000, TimeUnit.MILLISECONDS)
.withConnectionTimeout(15000, TimeUnit.MILLISECONDS)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not supported anymore if we use an existing HttpClient. No big deal.

.build();
var client =
new CloudHttp2SolrClient.Builder(
Expand Down
1 change: 0 additions & 1 deletion solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ private void requestRecovery(
try (SolrClient client =
new Http2SolrClient.Builder(baseUrl)
.withHttpClient(solrClient)
.withConnectionTimeout(30000, TimeUnit.MILLISECONDS)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not supported anymore if we use an existing HttpClient. No big deal.

.withIdleTimeout(120000, TimeUnit.MILLISECONDS)
.build()) {
client.request(recoverRequestCmd);
Expand Down
4 changes: 0 additions & 4 deletions solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ public class IndexFetcher {

private final Http2SolrClient solrClient;

private Integer connTimeout;

private Integer soTimeout;

private boolean skipCommitOnLeaderVersionZero = true;
Expand Down Expand Up @@ -258,7 +256,6 @@ private Http2SolrClient createSolrClient(
.withHttpClient(updateShardHandler.getRecoveryOnlyHttpClient())
.withBasicAuthCredentials(httpBasicAuthUser, httpBasicAuthPassword)
.withIdleTimeout(soTimeout, TimeUnit.MILLISECONDS)
.withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS)
.build();
}

Expand Down Expand Up @@ -287,7 +284,6 @@ public IndexFetcher(
String compress = (String) initArgs.get(COMPRESSION);
useInternalCompression = ReplicationHandler.INTERNAL.equals(compress);
useExternalCompression = ReplicationHandler.EXTERNAL.equals(compress);
connTimeout = getParameter(initArgs, HttpClientUtil.PROP_CONNECTION_TIMEOUT, 30000, null);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not supported anymore if we use an existing HttpClient. No big deal.

Here this setting comes from ReplicationHandler config in solrconfig.xml but I don't think anyone specifies this (I searched for it and didn't see in all of Solr configs/tests).

soTimeout = getParameter(initArgs, HttpClientUtil.PROP_SO_TIMEOUT, 120000, null);

String httpBasicAuthUser = (String) initArgs.get(HttpClientUtil.PROP_BASIC_AUTH_USER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ It is always strongly recommended that you fully reindex your documents after a
In Solr 8, it was possible to add docValues to a schema without re-indexing via `UninvertDocValuesMergePolicy`, an advanced/expert utility.
Due to changes in Lucene 9, that isn't possible any more.

== Solr 9.9

=== SolrJ

If Http2SolrClient.Builder.withHttpClient is used, (and it's used more in 9.8, shifted from deprecated Apache HttpClient based clients), settings affecting HttpClient construction cannot be customized; an IllegalStateException will now be thrown if you try.
The connection timeout cannot be customized, but idle & request timeouts can be.
Callers (various places in Solr) no longer customize the connection timeout.

== Solr 9.8.1
=== Configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,14 @@ private static Http2SolrClient.Builder newHttp2SolrClientBuilder(
.withDefaultCollection(URLUtil.extractCoreFromCoreUrl(url));
if (http2SolrClient != null) {
builder.withHttpClient(http2SolrClient);
// cannot set connection timeout
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay? I suppose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate that the http2SolrClient connectionTimeout is greater than or equal to the minConnTimeout? Maybe this validation should be in the constructor? There seems to be an expectation from the comments that this is the "floor" for some reason... But if this is actually irrelevant then does it make more sense to just rip out minConnTimeout altogether to avoid confusion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dug into this... the timeouts came from https://issues.apache.org/jira/browse/SOLR-14672 which is more about making them inheritable instead of hard-coded. We have that already -- they are inherited from the passed in client, which in turn has values that are configurable via HttpSolrClientProvider via UpdateShardHandlerConfig via solr.xml.
I think we're fine.

} else {
builder.withConnectionTimeout(minConnTimeout, TimeUnit.MILLISECONDS);
}
builder.withIdleTimeout(
Math.max(minSocketTimeout, builder.getIdleTimeoutMillis()), TimeUnit.MILLISECONDS);
builder.withOptionalBasicAuthCredentials(basicAuthCredentials);

long idleTimeout = minSocketTimeout;
if (builder.getIdleTimeoutMillis() != null) {
idleTimeout = Math.max(idleTimeout, builder.getIdleTimeoutMillis());
}
builder.withIdleTimeout(idleTimeout, TimeUnit.MILLISECONDS);
long connTimeout = minConnTimeout;
if (builder.getConnectionTimeout() != null) {
connTimeout = Math.max(idleTimeout, builder.getConnectionTimeout());
}
builder.withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS);
return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ void sendUpdateStream() throws Exception {
responseListener = out.getResponseListener();
}

// just wait for the headers, so the idle timeout is sensible
Response response =
responseListener.get(client.getIdleTimeout(), TimeUnit.MILLISECONDS);
rspBody = responseListener.getInputStream();
Expand Down
Loading
Loading