From f698963775e99c9ac0f938c6b91bb8c4a4e2dba3 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Mon, 20 Jan 2014 02:59:59 +0000 Subject: [PATCH] SOLR-5643: ConcurrentUpdateSolrServer will sometimes not spawn a new Runner thread even though there are updates in the queue. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1559620 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 +++ .../solrj/impl/ConcurrentUpdateSolrServer.java | 14 +++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index f1daa7ba14b..8e7fc4b664f 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -210,6 +210,9 @@ Bug Fixes distributed searching for some field types such as legacy numeric types (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.java index 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 alive scheduler.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 runners Runner r = new Runner(); runners.add(r); scheduler.execute(r);