Apache Lucene open-source search software
SOLR-13975: Make sure the stall time is adjusted up when an unusually long poll time is configured.
Andrzej Bialeckie155649026a6
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.javaindex bb0c5822f6e..0e224a1b85b 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java@@ -152,6 +152,9 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {this.streamDeletes = builder.streamDeletes;this.basePath = builder.baseSolrUrl;this.stallTime = Integer.getInteger("solr.cloud.client.stallTime", 15000);+ if (stallTime < pollQueueTime * 2) {+ throw new RuntimeException("Invalid stallTime: " + stallTime + "ms, must be 2x > pollQueueTime " + pollQueueTime);+ }if (builder.executorService != null) {this.scheduler = builder.executorService;@@ -214,7 +217,6 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {try {Update update;notifyQueueAndRunnersIfEmptyQueue();- //log.info("-- polling 1");update = queue.poll(pollQueueTime, TimeUnit.MILLISECONDS);if (update == null) {@@ -662,7 +664,12 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {*/public void setPollQueueTime(int pollQueueTime) {this.pollQueueTime = pollQueueTime;- this.stallTime = this.pollQueueTime * 3 / 2;+ // make sure the stall time is larger than the polling time+ // to give a chance for the queue to change+ int minimalStallTime = pollQueueTime * 2;+ if (minimalStallTime > this.stallTime) {+ this.stallTime = minimalStallTime;+ }}/**diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.javaindex d921cb2114a..edc8270cfc3 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java@@ -134,7 +134,9 @@ public class ConcurrentUpdateSolrClient extends SolrClient {this.connectionTimeout = builder.connectionTimeoutMillis;this.soTimeout = builder.socketTimeoutMillis;this.stallTime = Integer.getInteger("solr.cloud.client.stallTime", 15000);-+ if (stallTime < pollQueueTime * 2) {+ throw new RuntimeException("Invalid stallTime: " + stallTime + "ms, must be 2x > pollQueueTime " + pollQueueTime);+ }if (builder.executorService != null) {this.scheduler = builder.executorService;@@ -827,6 +829,12 @@ public class ConcurrentUpdateSolrClient extends SolrClient {*/public void setPollQueueTime(int pollQueueTime) {this.pollQueueTime = pollQueueTime;+ // make sure the stall time is larger than the polling time+ // to give a chance for the queue to change+ int minimalStallTime = pollQueueTime * 2;+ if (minimalStallTime > this.stallTime) {+ this.stallTime = minimalStallTime;+ }}public void setRequestWriter(RequestWriter requestWriter) {