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/07 23:07:57 UTC

[solr] branch main 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 main
in repository https://gitbox.apache.org/repos/asf/solr.git


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

commit 209ba014fb80e1fcf2de89ebb131ac556dc6d802
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                                                    | 3 +++
 .../apache/solr/update/processor/DistributedZkUpdateProcessor.java  | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 2c5b3ccbf8d..ab9e7f552c4 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -78,6 +78,9 @@ Improvements
 * SOLR-16490: The semi-internal `/admin/cores?action=restorecore` API now has a v2 equivalent, available at
   `POST /api/cores/coreName/restore {...}` (Sayanti Dey 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()
               + "/"