Skip to content

Commit dd89cd6

Browse files
dsmileykotman12
andauthored
SOLR-17776: Harmonize SolrJ timeouts (#3357)
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. The HttpJdkSolrClient wasn't setting the connection timeout as per the builder configuration. Co-authored-by: Luke Kot-Zaniewski <lkotzaniewsk@bloomberg.net>
1 parent 8a3e4c8 commit dd89cd6

14 files changed

Lines changed: 261 additions & 180 deletions

File tree

solr/CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ Improvements
250250
* SOLR-16951: Add PKI Auth Caching for both generation of the PKI Auth Tokens and validation of received tokens.
251251
The default PKI Auth validity TTL has been increased from 5 seconds to 10 seconds. (Houston Putman)
252252

253+
* SOLR-17776: SolrJ: If Http2SolrClient.Builder.withHttpClient is used, (and it's used more in 9.8, shifted from deprecated Apache HttpClient
254+
based clients), settings affecting HttpClient construction cannot be customized; an IllegalStateException will now be thrown if you try.
255+
The connection timeout cannot be customized, but idle & request timeouts can be. Callers (various places in Solr) no longer customize the connection timeout.
256+
(David Smiley, Luke Kot-Zaniewski)
257+
258+
* SOLR-17776: The HttpJdkSolrClient wasn't setting the connection timeout as per the builder configuration. (David Smiley)
259+
253260
Optimizations
254261
---------------------
255262
* SOLR-17578: Remove ZkController internal core supplier, for slightly faster reconnection after Zookeeper session loss. (Pierre Salagnac)

solr/core/src/java/org/apache/solr/cloud/Overseer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,6 @@ private void doCompatCheck(BiConsumer<String, Object> consumer) {
862862
new Http2SolrClient.Builder()
863863
.withHttpClient(getCoreContainer().getDefaultHttpSolrClient())
864864
.withIdleTimeout(30000, TimeUnit.MILLISECONDS)
865-
.withConnectionTimeout(15000, TimeUnit.MILLISECONDS)
866865
.build();
867866
var client =
868867
new CloudHttp2SolrClient.Builder(

solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ private void requestRecovery(
360360
try (SolrClient client =
361361
new Http2SolrClient.Builder(baseUrl)
362362
.withHttpClient(solrClient)
363-
.withConnectionTimeout(30000, TimeUnit.MILLISECONDS)
364363
.withIdleTimeout(120000, TimeUnit.MILLISECONDS)
365364
.build()) {
366365
client.request(recoverRequestCmd);

solr/core/src/java/org/apache/solr/handler/IndexFetcher.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ public class IndexFetcher {
179179

180180
private final Http2SolrClient solrClient;
181181

182-
private Integer connTimeout;
183-
184182
private Integer soTimeout;
185183

186184
private boolean skipCommitOnLeaderVersionZero = true;
@@ -258,7 +256,6 @@ private Http2SolrClient createSolrClient(
258256
.withHttpClient(updateShardHandler.getRecoveryOnlyHttpClient())
259257
.withBasicAuthCredentials(httpBasicAuthUser, httpBasicAuthPassword)
260258
.withIdleTimeout(soTimeout, TimeUnit.MILLISECONDS)
261-
.withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS)
262259
.build();
263260
}
264261

@@ -287,7 +284,6 @@ public IndexFetcher(
287284
String compress = (String) initArgs.get(COMPRESSION);
288285
useInternalCompression = ReplicationHandler.INTERNAL.equals(compress);
289286
useExternalCompression = ReplicationHandler.EXTERNAL.equals(compress);
290-
connTimeout = getParameter(initArgs, HttpClientUtil.PROP_CONNECTION_TIMEOUT, 30000, null);
291287
soTimeout = getParameter(initArgs, HttpClientUtil.PROP_SO_TIMEOUT, 120000, null);
292288

293289
String httpBasicAuthUser = (String) initArgs.get(HttpClientUtil.PROP_BASIC_AUTH_USER);

solr/solr-ref-guide/modules/upgrade-notes/pages/major-changes-in-solr-9.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ It is always strongly recommended that you fully reindex your documents after a
6767
In Solr 8, it was possible to add docValues to a schema without re-indexing via `UninvertDocValuesMergePolicy`, an advanced/expert utility.
6868
Due to changes in Lucene 9, that isn't possible any more.
6969

70+
== Solr 9.9
71+
72+
=== SolrJ
73+
74+
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.
75+
The connection timeout cannot be customized, but idle & request timeouts can be.
76+
Callers (various places in Solr) no longer customize the connection timeout.
77+
7078
== Solr 9.8.1
7179
=== Configuration
7280

solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/SolrClientCache.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,14 @@ private static Http2SolrClient.Builder newHttp2SolrClientBuilder(
205205
.withDefaultCollection(URLUtil.extractCoreFromCoreUrl(url));
206206
if (http2SolrClient != null) {
207207
builder.withHttpClient(http2SolrClient);
208+
// cannot set connection timeout
209+
} else {
210+
builder.withConnectionTimeout(minConnTimeout, TimeUnit.MILLISECONDS);
208211
}
212+
builder.withIdleTimeout(
213+
Math.max(minSocketTimeout, builder.getIdleTimeoutMillis()), TimeUnit.MILLISECONDS);
209214
builder.withOptionalBasicAuthCredentials(basicAuthCredentials);
210215

211-
long idleTimeout = minSocketTimeout;
212-
if (builder.getIdleTimeoutMillis() != null) {
213-
idleTimeout = Math.max(idleTimeout, builder.getIdleTimeoutMillis());
214-
}
215-
builder.withIdleTimeout(idleTimeout, TimeUnit.MILLISECONDS);
216-
long connTimeout = minConnTimeout;
217-
if (builder.getConnectionTimeout() != null) {
218-
connTimeout = Math.max(idleTimeout, builder.getConnectionTimeout());
219-
}
220-
builder.withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS);
221216
return builder;
222217
}
223218

solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ void sendUpdateStream() throws Exception {
255255
responseListener = out.getResponseListener();
256256
}
257257

258+
// just wait for the headers, so the idle timeout is sensible
258259
Response response =
259260
responseListener.get(client.getIdleTimeout(), TimeUnit.MILLISECONDS);
260261
rspBody = responseListener.getInputStream();

0 commit comments

Comments
 (0)