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

[solr] branch branch_9x updated: SOLR-15732: queries to missing collection are slow (#1207)

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

noble 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 f1638b15ddf SOLR-15732: queries to missing collection are slow (#1207)
f1638b15ddf is described below

commit f1638b15ddf6fc8c0719c95650d95a4c58ab21d3
Author: Noble Paul <no...@users.noreply.github.com>
AuthorDate: Tue Dec 6 15:26:12 2022 +1100

    SOLR-15732: queries to missing collection are slow (#1207)
---
 solr/CHANGES.txt                                              |  4 ++++
 solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java  | 10 +++++++++-
 .../src/java/org/apache/solr/common/cloud/ZkStateReader.java  | 11 +++++++++--
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 47f75e3eac3..88af9931d25 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -57,6 +57,7 @@ Improvements
   (Houston Putman)
 
 * SOLR-16565: posting the same file to the package store should not throw an error (noble)
+
 Optimizations
 ---------------------
 
@@ -64,6 +65,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.java
index 8798a3c3ee7..c9d62bcfc3b 100644
--- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
+++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java
@@ -475,7 +475,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.java
index 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()));
     }