Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-6807: fix _stateVer_ param check to not depend on handleSelect setting

David Smiley811621c6ea63
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 214b82ef70e..39fc14c27c5 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -229,6 +229,9 @@ Bug Fixes
* SOLR-10506: Fix memory leak (upon collection reload or ZooKeeper session expiry) in ZkIndexSchemaReader.
(Torsten Bøgh Köster, Christine Poerschke, Jörg Rathlev, Mike Drob)
+* SOLR-6807: CloudSolrClient's ZK state version check with the server was ignored when handleSelect=false
+ (David Smiley)
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
index 5542d4c9fbf..a548c05389c 100644
--- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
+++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
@@ -327,6 +327,8 @@ public class HttpSolrCall {
solrReq = parser.parse(core, path, req);
}
+ invalidStates = checkStateVersionsAreValid(solrReq.getParams().get(CloudSolrClient.STATE_VERSION));
+
if (usingAliases) {
processAliases(aliases, collectionsList);
}
@@ -388,8 +390,6 @@ public class HttpSolrCall {
/**
* Extract handler from the URL path if not set.
- * This returns true if the action is set.
- *
*/
protected void extractHandlerFromURLPath(SolrRequestParsers parser) throws Exception {
if (handler == null && path.length() > 1) { // don't match "" or "/" as valid path
@@ -411,14 +411,12 @@ public class HttpSolrCall {
return;
}
}
-
}
- // no handler yet but allowed to handle select; let's check
+ // no handler yet but <requestDispatcher> allows us to handle /select with a 'qt' param
if (handler == null && parser.isHandleSelect()) {
if ("/select".equals(path) || "/select/".equals(path)) {
solrReq = parser.parse(core, path, req);
- invalidStates = checkStateIsValid(solrReq.getParams().get(CloudSolrClient.STATE_VERSION));
String qt = solrReq.getParams().get(CommonParams.QT);
handler = core.getRequestHandler(qt);
if (handler == null) {
@@ -438,7 +436,7 @@ public class HttpSolrCall {
if (core == null && idx > 0) {
coreUrl = getRemotCoreUrl(corename, origCorename);
// don't proxy for internal update requests
- invalidStates = checkStateIsValid(queryParams.get(CloudSolrClient.STATE_VERSION));
+ invalidStates = checkStateVersionsAreValid(queryParams.get(CloudSolrClient.STATE_VERSION));
if (coreUrl != null
&& queryParams
.get(DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM) == null) {
@@ -813,7 +811,8 @@ public class HttpSolrCall {
}
}
- private Map<String, Integer> checkStateIsValid(String stateVer) {
+ /** Returns null if the state ({@link CloudSolrClient#STATE_VERSION}) is good; otherwise returns state problems. */
+ private Map<String, Integer> checkStateVersionsAreValid(String stateVer) {
Map<String, Integer> result = null;
String[] pairs;
if (stateVer != null && !stateVer.isEmpty() && cores.isZooKeeperAware()) {