You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2019/02/28 20:53:22 UTC

[lucene-solr] 03/06: SOLR-13271: Use the core.indexEnabled flag to fail-fast ongoing updates.

This is an automated email from the ASF dual-hosted git repository.

ab pushed a commit to branch jira/solr-11127-2
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 7021ef5cfb2d17220abcb703f770d8cf96c76df3
Author: Andrzej Bialecki <ab...@apache.org>
AuthorDate: Thu Feb 28 17:35:54 2019 +0100

    SOLR-13271: Use the core.indexEnabled flag to fail-fast ongoing updates.
---
 .../update/processor/DistributedUpdateProcessor.java   | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
index 505097f..5f95f72 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
@@ -184,7 +184,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
   private Set<String> skippedCoreNodeNames;
   private boolean isIndexChanged = false;
 
-  private boolean readOnly = false;
+  private boolean readOnlyCollection = false;
 
   /**
    * Number of times requests forwarded to some other shard's leader can be retried
@@ -254,7 +254,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
       DocCollection coll = zkController.getClusterState().getCollectionOrNull(collection);
       if (coll != null) {
         // check readOnly property in coll state
-        readOnly = coll.getBool(ZkStateReader.READ_ONLY, false);
+        readOnlyCollection = coll.getBool(ZkStateReader.READ_ONLY, false);
       }
     } else {
       collection = null;
@@ -276,6 +276,10 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
     cloneRequiredOnLeader = shouldClone;
   }
 
+  private boolean isReadOnly() {
+    return readOnlyCollection || !req.getCore().indexEnabled;
+  }
+
   private List<Node> setupRequest(String id, SolrInputDocument doc) {
     return setupRequest(id, doc, null);
   }
@@ -678,7 +682,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
 
     assert TestInjection.injectFailUpdateRequests();
 
-    if (readOnly) {
+    if (isReadOnly()) {
       throw new SolrException(ErrorCode.FORBIDDEN, "Collection " + collection + " is read-only.");
     }
 
@@ -1430,7 +1434,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
     
     assert TestInjection.injectFailUpdateRequests();
 
-    if (readOnly) {
+    if (isReadOnly()) {
       throw new SolrException(ErrorCode.FORBIDDEN, "Collection " + collection + " is read-only.");
     }
 
@@ -1943,7 +1947,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
     
     assert TestInjection.injectFailUpdateRequests();
 
-    if (readOnly) {
+    if (isReadOnly()) {
       throw new SolrException(ErrorCode.FORBIDDEN, "Collection " + collection + " is read-only.");
     }
 
@@ -2059,7 +2063,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
 
   @Override
   public void processMergeIndexes(MergeIndexesCommand cmd) throws IOException {
-    if (readOnly) {
+    if (isReadOnly()) {
       throw new SolrException(ErrorCode.FORBIDDEN, "Collection " + collection + " is read-only.");
     }
     super.processMergeIndexes(cmd);
@@ -2067,7 +2071,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
 
   @Override
   public void processRollback(RollbackUpdateCommand cmd) throws IOException {
-    if (readOnly) {
+    if (isReadOnly()) {
       throw new SolrException(ErrorCode.FORBIDDEN, "Collection " + collection + " is read-only.");
     }
     super.processRollback(cmd);