You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2023/08/08 01:27:06 UTC

[solr] branch branch_9x updated: SOLR-11685: use HTTP INVALID_STATE for ZK state issues in DistributedZkUpdateProcessor (#1484)

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

dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new f60b75c3623 SOLR-11685: use HTTP INVALID_STATE for ZK state issues in DistributedZkUpdateProcessor (#1484)
f60b75c3623 is described below

commit f60b75c36238c555c5d767d99f01debb3c4ee156
Author: David Smiley <ds...@salesforce.com>
AuthorDate: Mon Aug 7 19:07:51 2023 -0400

    SOLR-11685: use HTTP INVALID_STATE for ZK state issues in DistributedZkUpdateProcessor (#1484)
    
    When SolrCloud shard leaders change while indexing updates arrive, Solr could fail and return
      a HTTP 503 status. Switched to 510 so that CloudSolrClient will auto-retry it and probably succeed.
---
 solr/CHANGES.txt                                                    | 4 ++++
 .../apache/solr/update/processor/DistributedZkUpdateProcessor.java  | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index c21ff5e7a0d..8c137451704 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -19,6 +19,10 @@ Improvements
 
 * SOLR-16847: v2 APIs are now able to access any applicable solrconfig.xml "requestHandler" configuration. (Alex Deparvu via Jason Gerlowski)
 
+* SOLR-11685: When SolrCloud shard leaders change while indexing updates arrive, Solr could fail and return
+  a HTTP 503 status. Switched to 510 so that CloudSolrClient will auto-retry it and probably succeed.
+  (David Smiley, Alex Deparvu)
+
 Optimizations
 ---------------------
 
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
index 202eac239bd..a1e491c82bb 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
@@ -1156,7 +1156,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
       if (fromShard != null) {
         if (mySlice.getState() == Slice.State.ACTIVE) {
           throw new SolrException(
-              SolrException.ErrorCode.SERVICE_UNAVAILABLE,
+              ErrorCode.INVALID_STATE,
               "Request says it is coming from parent shard leader but we are in active state");
         }
         // shard splitting case -- check ranges to see if we are a sub-shard
@@ -1178,7 +1178,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
               req.getParamString());
           SolrException solrExc =
               new SolrException(
-                  SolrException.ErrorCode.SERVICE_UNAVAILABLE,
+                  ErrorCode.INVALID_STATE,
                   "Request says it is coming from leader, but we are the leader");
           solrExc.setMetadata("cause", "LeaderChanged");
           throw solrExc;
@@ -1201,7 +1201,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor {
     if ((isLeader && !localIsLeader) || (isSubShardLeader && !localIsLeader)) {
       log.error("ClusterState says we are the leader, but locally we don't think so");
       throw new SolrException(
-          SolrException.ErrorCode.SERVICE_UNAVAILABLE,
+          ErrorCode.INVALID_STATE,
           "ClusterState says we are the leader ("
               + zkController.getBaseUrl()
               + "/"