You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2019/05/20 17:49:23 UTC
[lucene-solr] branch branch_8x updated: SOLR-13474: Fix "Search is
temporarily disabled" logic to be consistent for entire request
This is an automated email from the ASF dual-hosted git repository.
hossman pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new 4dd3186 SOLR-13474: Fix "Search is temporarily disabled" logic to be consistent for entire request
4dd3186 is described below
commit 4dd3186c0f1d7ab78f30981acda527b85cfb8bdc
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Mon May 20 10:24:02 2019 -0700
SOLR-13474: Fix "Search is temporarily disabled" logic to be consistent for entire request
SOLR-13469: Fix rejected requests during full disk full + IndexFetch to use 503 not 403
(cherry picked from commit 6cc67e433e191b5c0450a4d2fc06de26939ac920)
Conflicts:
solr/CHANGES.txt
---
solr/CHANGES.txt | 8 ++++++++
solr/core/src/java/org/apache/solr/core/SolrCore.java | 13 ++++++-------
.../java/org/apache/solr/request/SolrQueryRequestBase.java | 4 ----
.../java/org/apache/solr/update/DefaultSolrCoreState.java | 3 ++-
.../solr/handler/TestReplicationHandlerDiskOverFlow.java | 5 ++---
5 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d09da48..a0ad031 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -50,6 +50,14 @@ New Features
* SOLR-12304: The MoreLikeThisComponent now supports the mlt.interestingTerms parameter. Previously this option was
unique to the MLT handler. (Alessandro Benedetti via David Smiley)
+Bug Fixes
+----------------------
+
+* 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.java
index c86ceb4..e77b70e 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, Closeab
private 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();
@@ -1880,7 +1876,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.java
index 92562f0..ed6f953 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.java
index 87a885f..3844040 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 Recover
public 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.java
index 368d08f..8a25a41 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