lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tflo...@apache.org
Subject [31/50] [abbrv] lucene-solr:jira/solr-10233: SOLR-10615: latching SDF.doFilter() on init(); respond 404 instead of 500 in case of init failures or corecontainer shutdown.
Date Mon, 08 May 2017 22:07:45 GMT
SOLR-10615: latching SDF.doFilter() on init(); respond 404 instead of 500 in case of init failures
or corecontainer shutdown.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/c02d490d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/c02d490d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/c02d490d

Branch: refs/heads/jira/solr-10233
Commit: c02d490d2113c2b3fbe5826f334592cdb65a3dfe
Parents: 5883710
Author: Mikhail Khludnev <mkhl@apache.org>
Authored: Sat May 6 00:36:00 2017 +0300
Committer: Mikhail Khludnev <mkhl@apache.org>
Committed: Sat May 6 10:47:27 2017 +0300

----------------------------------------------------------------------
 solr/CHANGES.txt                                    |  4 ++++
 .../org/apache/solr/servlet/SolrDispatchFilter.java | 16 +++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c02d490d/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 3fbfc96..38aac79 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -302,6 +302,10 @@ Bug Fixes
 
 * SOLR-10549: The new 'large' attribute had been forgotten in /schema/fieldtypes?showDefaults=true
(David Smiley)
 
+* SOLR-10615: requests are suspended until SolrDispatchFilter initialization is completed.

+  After core container shutdown or severe initialization problem Solr responds with 
+  http stauts 404 Not Found instead of 500 as it was before (Mikhail Khludnev) 
+
 Other Changes
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c02d490d/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
index a4c9504..24440e7 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -29,6 +29,7 @@ import java.util.Arrays;
 import java.util.Locale;
 import java.util.Properties;
 import java.util.Set;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.regex.Matcher;
@@ -41,6 +42,7 @@ import javax.servlet.ServletInputStream;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
+import javax.servlet.UnavailableException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequestWrapper;
 import javax.servlet.http.HttpServletResponse;
@@ -88,6 +90,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   protected volatile CoreContainer cores;
+  protected final CountDownLatch init = new CountDownLatch(1);
 
   protected String abortErrorMessage = null;
   protected HttpClient httpClient;
@@ -187,6 +190,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
     }finally{
       log.trace("SolrDispatchFilter.init() done");
       this.cores = coresInit; // crucially final assignment 
+      init.countDown();
     }
   }
 
@@ -318,9 +322,15 @@ public class SolrDispatchFilter extends BaseSolrFilter {
     try {
 
       if (cores == null || cores.isShutDown()) {
-        log.error("Error processing the request. CoreContainer is either not initialized
or shutting down.");
-        throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE,
-            "Error processing the request. CoreContainer is either not initialized or shutting
down.");
+        try {
+          init.await();
+        } catch (InterruptedException e) { //well, no wait then
+        }
+        final String msg = "Error processing the request. CoreContainer is either not initialized
or shutting down.";
+        if (cores == null || cores.isShutDown()) {
+          log.error(msg);
+          throw new UnavailableException(msg);
+        }
       }
 
       AtomicReference<ServletRequest> wrappedRequest = new AtomicReference<>();


Mime
View raw message