You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2020/02/05 21:16:31 UTC

[lucene-solr] branch branch_8x updated: SOLR-13887: Use the default idleTimeout instead of 0 for HTTP2 (#991)

This is an automated email from the ASF dual-hosted git repository.

houston pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new e0d35f9  SOLR-13887: Use the default idleTimeout instead of 0 for HTTP2 (#991)
e0d35f9 is described below

commit e0d35f964169a0d1efb686f2e2586c896194c02c
Author: Houston Putman <ho...@apache.org>
AuthorDate: Wed Feb 5 11:15:37 2020 -0800

    SOLR-13887: Use the default idleTimeout instead of 0 for HTTP2 (#991)
---
 solr/CHANGES.txt                                              |  2 ++
 solr/solr-ref-guide/src/format-of-solr-xml.adoc               | 10 +++++-----
 .../org/apache/solr/client/solrj/impl/Http2SolrClient.java    |  4 ++--
 .../apache/solr/client/solrj/impl/Http2SolrClientTest.java    | 11 +++++++++++
 4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 4066219..151ed70 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -188,6 +188,8 @@ Bug Fixes
 * SOLR-14219: SOLR-14095 Introduced an issue for rolling restarts (Incompatible Java serialization). This change
   Fixes the compatibility issue while keeping the functionality in SOLR-14095. (Andy Webb, Tomás Fernández Löbbe)
 
+* SOLR-13887: Use default idleTimeout instead of 0 for HTTP2 requests. (Houston Putman)
+
 Other Changes
 ---------------------
 
diff --git a/solr/solr-ref-guide/src/format-of-solr-xml.adoc b/solr/solr-ref-guide/src/format-of-solr-xml.adoc
index 899da94..0190203 100644
--- a/solr/solr-ref-guide/src/format-of-solr-xml.adoc
+++ b/solr/solr-ref-guide/src/format-of-solr-xml.adoc
@@ -40,8 +40,8 @@ You can find `solr.xml` in your `$SOLR_HOME` directory (usually `server/solr`) i
 
   <shardHandlerFactory name="shardHandlerFactory"
     class="HttpShardHandlerFactory">
-    <int name="socketTimeout">${socketTimeout:0}</int>
-    <int name="connTimeout">${connTimeout:0}</int>
+    <int name="socketTimeout">${socketTimeout:600000}</int>
+    <int name="connTimeout">${connTimeout:600000}</int>
   </shardHandlerFactory>
 
 </solr>
@@ -232,15 +232,15 @@ Solr supports variable substitution of JVM system property values in `solr.xml`,
 
 Any JVM system properties usually specified using the `-D` flag when starting the JVM, can be used as variables in the `solr.xml` file.
 
-For example, in the `solr.xml` file shown below, the `socketTimeout` and `connTimeout` values are each set to "0". However, if you start Solr using `bin/solr -DsocketTimeout=1000`, the `socketTimeout` option of the `HttpShardHandlerFactory` to be overridden using a value of 1000ms, while the `connTimeout` option will continue to use the default property value of "0".
+For example, in the `solr.xml` file shown below, the `socketTimeout` and `connTimeout` values are each set to "60000". However, if you start Solr using `bin/solr -DsocketTimeout=1000`, the `socketTimeout` option of the `HttpShardHandlerFactory` to be overridden using a value of 1000ms, while the `connTimeout` option will continue to use the default property value of "60000".
 
 [source,xml]
 ----
 <solr>
   <shardHandlerFactory name="shardHandlerFactory"
                        class="HttpShardHandlerFactory">
-    <int name="socketTimeout">${socketTimeout:0}</int>
-    <int name="connTimeout">${connTimeout:0}</int>
+    <int name="socketTimeout">${socketTimeout:60000}</int>
+    <int name="connTimeout">${connTimeout:60000}</int>
   </shardHandlerFactory>
 </solr>
 ----
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
index 8c6e546..32eddc1 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
@@ -146,7 +146,7 @@ public class Http2SolrClient extends SolrClient {
       this.serverBaseUrl = serverBaseUrl;
     }
 
-    if (builder.idleTimeout != null) idleTimeout = builder.idleTimeout;
+    if (builder.idleTimeout != null && builder.idleTimeout > 0) idleTimeout = builder.idleTimeout;
     else idleTimeout = HttpClientUtil.DEFAULT_SO_TIMEOUT;
 
     if (builder.http2SolrClient == null) {
@@ -215,7 +215,7 @@ public class Http2SolrClient extends SolrClient {
     httpClient.setMaxRequestsQueuedPerDestination(asyncTracker.getMaxRequestsQueuedPerDestination());
     httpClient.setUserAgentField(new HttpField(HttpHeader.USER_AGENT, AGENT));
 
-    if (builder.idleTimeout != null) httpClient.setIdleTimeout(builder.idleTimeout);
+    httpClient.setIdleTimeout(idleTimeout);
     if (builder.connectionTimeout != null) httpClient.setConnectTimeout(builder.connectionTimeout);
     try {
       httpClient.start();
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java
index 06e4ba9..6462f2c 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java
@@ -183,6 +183,17 @@ public class Http2SolrClientTest extends SolrJettyTestBase {
 
   }
 
+  @Test
+  public void test0IdleTimeout() throws Exception {
+    SolrQuery q = new SolrQuery("*:*");
+    try(Http2SolrClient client = getHttp2SolrClient(jetty.getBaseUrl().toString() + "/debug/foo", DEFAULT_CONNECTION_TIMEOUT, 0)) {
+      try {
+        client.query(q, SolrRequest.METHOD.GET);
+      } catch (ParseException ignored) {}
+    }
+
+  }
+
   /**
    * test that SolrExceptions thrown by HttpSolrClient can
    * correctly encapsulate http status codes even when not on the list of