Apache Solr open-source search software
SOLR-13474: Fix "Search is temporarily disabled" logic to be consistent for entire request
Chris Hostetter6cc67e433e19
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex f00de53631a..c91e979dde0 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -98,6 +98,10 @@ Bug Fixes* SOLR-13475: Null Pointer Exception when querying collection through collection alias. (Jörn Franke, ab)+* SOLR-13474: Fix "Search is temporarily disabled" logic to be consistent for entire request (hossman)++* SOLR-13469: Fix rejected requests during full disk full + IndexFetch to use 503 not 403 (hossman)+Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.javaindex d850aa1c8ac..1c7234aefc2 100644--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java@@ -235,18 +235,14 @@ public final class SolrCore implements SolrInfoBean, SolrMetricProducer, Closeabprivate Set<String> metricNames = ConcurrentHashMap.newKeySet();private String metricTag = Integer.toHexString(hashCode());- public boolean searchEnabled = true;- public boolean indexEnabled = true;+ public volatile boolean searchEnabled = true;+ public volatile boolean indexEnabled = true;public volatile boolean readOnly = false;public Set<String> getMetricNames() {return metricNames;}- public boolean isSearchEnabled(){- return searchEnabled;- }-public Date getStartTimeStamp() { return startTime; }private final Map<IndexReader.CacheKey, IndexFingerprint> perSegmentFingerprintCache = new MapMaker().weakKeys().makeMap();@@ -1869,7 +1865,10 @@ public final class SolrCore implements SolrInfoBean, SolrMetricProducer, Closeab* @see #withSearcher(IOFunction)*/public RefCounted<SolrIndexSearcher> getSearcher() {- return getSearcher(false,true,null);+ if ( searchEnabled ) {+ return getSearcher(false,true,null);+ }+ throw new SolrException( SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Search is temporarily disabled");}/**diff --git a/solr/core/src/java/org/apache/solr/request/SolrQueryRequestBase.java b/solr/core/src/java/org/apache/solr/request/SolrQueryRequestBase.javaindex 92562f0740b..ed6f9534527 100644--- a/solr/core/src/java/org/apache/solr/request/SolrQueryRequestBase.java+++ b/solr/core/src/java/org/apache/solr/request/SolrQueryRequestBase.java@@ -119,10 +119,6 @@ public abstract class SolrQueryRequestBase implements SolrQueryRequest, Closeabl// should the core populate one in a factory method to create requests?// or there could be a setSearcher() method that Solr calls- if(!core.isSearchEnabled()){- throw new SolrException( SolrException.ErrorCode.FORBIDDEN,"Search is temporarily disabled");- }-if (searcherHolder==null) {searcherHolder = core.getSearcher();}diff --git a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.javaindex 87a885f4364..3844040ff07 100644--- a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java+++ b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java@@ -117,7 +117,8 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recoverpublic RefCounted<IndexWriter> getIndexWriter(SolrCore core)throws IOException {if (core != null && (!core.indexEnabled || core.readOnly)) {- throw new SolrException(SolrException.ErrorCode.FORBIDDEN, "Indexing is temporarily disabled");+ throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE,+ "Indexing is temporarily disabled");}boolean succeeded = false;lock(iwLock.readLock());diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerDiskOverFlow.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerDiskOverFlow.javaindex 368d08f33d9..8a25a41e5f8 100644--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerDiskOverFlow.java+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerDiskOverFlow.java@@ -156,9 +156,8 @@ public class TestReplicationHandlerDiskOverFlow extends SolrTestCaseJ4 {.setRows(0));Thread.sleep(200);} catch (SolrException e) {- // TODO: SOLR-13469: why is this FORBIDDEN(403) and not SERVICE_UNAVAILABLE(503)- if (e.code() == SolrException.ErrorCode.FORBIDDEN.code- // TODO: // && e.getMessage().contains(expectedErr) // why is this not always set?+ if (e.code() == SolrException.ErrorCode.SERVICE_UNAVAILABLE.code+ && e.getMessage().contains(expectedErr)) {log.info("Got expected exception", e);// now let the barrier complete & clear itself, and we're done