lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r1063871 - in /lucene/dev/branches/branch_3x: ./ lucene/ solr/ solr/CHANGES.txt solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java
Date Wed, 26 Jan 2011 21:11:56 GMT
Author: yonik
Date: Wed Jan 26 21:11:55 2011
New Revision: 1063871

URL: http://svn.apache.org/viewvc?rev=1063871&view=rev
Log:
SOLR-1711: fix hang when queue is full but there are no runners

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/CHANGES.txt
    lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java

Modified: lucene/dev/branches/branch_3x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/CHANGES.txt?rev=1063871&r1=1063870&r2=1063871&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/solr/CHANGES.txt Wed Jan 26 21:11:55 2011
@@ -347,7 +347,8 @@ Bug Fixes
 * SOLR-1711: SolrJ - StreamingUpdateSolrServer had a race condition that
   could halt the streaming of documents. The original patch to fix this
   (never officially released) introduced another hanging bug due to
-  connections not being released.  (Attila Babo, Erik Hetzner via yonik)
+  connections not being released.
+  (Attila Babo, Erik Hetzner, Johannes Tuchscherer via yonik)
   
 * SOLR-1748, SOLR-1747, SOLR-1746, SOLR-1745, SOLR-1744: Streams and Readers
   retrieved from ContentStreams are not closed in various places, resulting

Modified: lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java?rev=1063871&r1=1063870&r2=1063871&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java
(original)
+++ lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java
Wed Jan 26 21:11:55 2011
@@ -173,12 +173,20 @@ public class StreamingUpdateSolrServer e
       }
       catch (Throwable e) {
         handleError( e );
-      } 
+      }
       finally {
-        // remove it from the list of running things...
+
+        // 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.
         synchronized (runners) {
-          runners.remove( this );
+          if (runners.size() == 1 && queue.remainingCapacity() == 0) {
+           // keep this runner alive
+           scheduler.execute(this);
+          } else {
+            runners.remove( this );
+          }
         }
+
         log.info( "finished: {}" , this );
         runnerLock.unlock();
       }
@@ -208,7 +216,7 @@ public class StreamingUpdateSolrServer e
         return super.request( request );
       }
     }
-    
+
     try {
       CountDownLatch tmpLock = lock;
       if( tmpLock != null ) {
@@ -216,18 +224,18 @@ public class StreamingUpdateSolrServer e
       }
 
       queue.put( req );
-      
-        synchronized( runners ) {
-      if( runners.isEmpty() 
-        || (queue.remainingCapacity() < queue.size() 
-         && runners.size() < threadCount) ) 
-      {
+
+      synchronized( runners ) {
+        if( runners.isEmpty()
+                || (queue.remainingCapacity() < queue.size()
+                && runners.size() < threadCount) )
+        {
           Runner r = new Runner();
           scheduler.execute( r );
           runners.add( r );
         }
       }
-    } 
+    }
     catch (InterruptedException e) {
       log.error( "interrupted", e );
       throw new IOException( e.getLocalizedMessage() );



Mime
View raw message