Apache Solr open-source search software
SOLR-15732: queries to missing collection are slow (#1207)
Noble Paul704f3960ad6a
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex e86ec35c31e..2456af2f334 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -81,6 +81,7 @@ Improvements(Houston Putman)* SOLR-16565: posting the same file to the package store should not throw an error (noble)+Optimizations---------------------@@ -88,6 +89,9 @@ Optimizations* SOLR-16555: SolrIndexSearcher - FilterCache intersections/andNot should not clone bitsets repeatedly (Kevin Risden, David Smiley)+* SOLR-15732: queries to missing collection are slow (noble)++Bug Fixes---------------------diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.javaindex debd481a9a3..4a453d6f897 100644--- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java+++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java@@ -469,7 +469,15 @@ public class HttpSolrCall {} else {if (!retry) {// we couldn't find a core to work with, try reloading aliases & this collection- cores.getZkController().getZkStateReader().aliasesManager.update();+ if (!cores.getZkController().getZkStateReader().aliasesManager.update()+ && !cores+ .getZkController()+ .zkStateReader+ .getZkClient()+ .exists(DocCollection.getCollectionPath(collectionName), true)) {+ // no change and such a collection does not exist. go back+ return;+ }cores.getZkController().zkStateReader.forceUpdateCollection(collectionName);action = RETRY;}diff --git a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.javaindex 7e2c626431c..9011f750876 100644--- a/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java+++ b/solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java@@ -2289,10 +2289,17 @@ public class ZkStateReader implements SolrCloseable {* @return true if an update was performed*/public boolean update() throws KeeperException, InterruptedException {- log.debug("Checking ZK for most up to date Aliases {}", ALIASES);+ if (log.isDebugEnabled()) {+ log.debug("Checking ZK for most up to date Aliases {}", ALIASES);+ }+ Stat stat = zkClient.getZooKeeper().exists(ALIASES, null);+ if (stat == null || stat.getVersion() <= aliases.getZNodeVersion()) {+ return false;+ } else {+ stat = new Stat();+ }// Call sync() first to ensure the subsequent read (getData) is up to date.zkClient.getZooKeeper().sync(ALIASES, null, null);- Stat stat = new Stat();final byte[] data = zkClient.getData(ALIASES, null, stat, true);return setIfNewer(Aliases.fromJSON(data, stat.getVersion()));}