Apache Lucene open-source search software
SOLR-5643: ConcurrentUpdateSolrServer will sometimes not spawn a new Runner thread even though there are updates in the queue.
Mark Robert Millerf698963775e9
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex f1daa7ba14b..8e7fc4b664f 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -210,6 +210,9 @@ Bug Fixesdistributed searching for some field types such as legacy numerictypes (Rob Muir, Mike McCandless)+* SOLR-5643: ConcurrentUpdateSolrServer will sometimes not spawn a new Runner+ thread even though there are updates in the queue. (Mark Miller)+Optimizations----------------------diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.javaindex 5f23f38e473..8f940d455d2 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java@@ -255,16 +255,8 @@ public class ConcurrentUpdateSolrServer extends SolrServer {}handleError(e);} finally {-- // remove it from the list of running things unless we are the last- // runner and the queue is full...- // in which case, the next queue.put() would block and there would be no- // runners to handle it.- // This case has been further handled by using offer instead of put, and- // using a retry loop- // to avoid blocking forever (see request()).synchronized (runners) {- if (runners.size() == 1 && queue.remainingCapacity() == 0) {+ if (runners.size() == 1 && !queue.isEmpty()) {// keep this runner alivescheduler.execute(this);} else {@@ -394,6 +386,10 @@ public class ConcurrentUpdateSolrServer extends SolrServer {runner.runnerLock.lock();runner.runnerLock.unlock();} else if (!queue.isEmpty()) {+ // failsafe - should not be necessary, but a good+ // precaution to ensure blockUntilFinished guarantees+ // all updates are emptied from the queue regardless of+ // any bugs around starting or retaining runnersRunner r = new Runner();runners.add(r);scheduler.execute(r);