Apache Solr open-source search software
SOLR-11685: use HTTP INVALID_STATE for ZK state issues in DistributedZkUpdateProcessor (#1484)
David Smiley209ba014fb80
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 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.javaindex 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()+ "/"