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

noble pushed a commit to branch jira/SOLR-16636_revert
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/jira/SOLR-16636_revert by this 
push:
     new de63cb4e4c8 Revert "SOLR-16636: ZkStateReader.waitForState should not 
register a watch if state already matches predicate (#1318)"
de63cb4e4c8 is described below

commit de63cb4e4c85d1f68f8edf9458fe6b10a2271152
Author: Noble Paul <[email protected]>
AuthorDate: Wed Feb 8 10:02:20 2023 +1100

    Revert "SOLR-16636: ZkStateReader.waitForState should not register a watch 
if state already matches predicate (#1318)"
    
    This reverts commit 47c235a38b316b77940945da33baf6d02a02cefc.
    
    reverted for perf testing
---
 .../apache/solr/common/cloud/ZkStateReader.java    | 41 +---------------------
 .../org/apache/solr/common/cloud/ClusterState.java |  8 -----
 2 files changed, 1 insertion(+), 48 deletions(-)

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 c7173173ef2..d714dfee54c 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
@@ -832,11 +832,6 @@ public class ZkStateReader implements SolrCloseable {
       return cachedDocCollection;
     }
 
-    @Override
-    public DocCollection getOrNull() {
-      return cachedDocCollection;
-    }
-
     @Override
     public boolean isLazilyLoaded() {
       return true;
@@ -1687,37 +1682,6 @@ public class ZkStateReader implements SolrCloseable {
     }
   }
 
-  /**
-   * fetch the collection that is already cached. This may return a null if it 
is not already cached
-   * This is an optimization to avoid fetching state if it is not modified. 
this is particularly
-   * true for PRS collections where state is rarely modified
-   */
-  private DocCollection fetchCachedCollection(String coll) {
-    String collectionPath = DocCollection.getCollectionPath(coll);
-    DocCollection c = null;
-    ClusterState.CollectionRef ref = clusterState.getCollectionRef(coll);
-    if (ref == null) return null;
-    c = ref.getOrNull();
-    if (c == null) return null;
-    Stat stat = null;
-    try {
-      stat = zkClient.exists(collectionPath, null, false);
-    } catch (Exception e) {
-      return null;
-    }
-    if (stat != null) {
-      if (!c.isModified(stat.getVersion(), stat.getCversion())) {
-        // we have the latest collection state
-        return c;
-      }
-      if (c.isPerReplicaState() && c.getChildNodesVersion() < 
stat.getCversion()) {
-        // only PRS is modified. just fetch it and return the new collection
-        return c.copyWith(PerReplicaStatesFetcher.fetch(collectionPath, 
zkClient, null));
-      }
-    }
-    return null;
-  }
-
   private DocCollection fetchCollectionState(String coll, Watcher watcher)
       throws KeeperException, InterruptedException {
     String collectionPath = DocCollection.getCollectionPath(coll);
@@ -1905,8 +1869,6 @@ public class ZkStateReader implements SolrCloseable {
     if (closed) {
       throw new AlreadyClosedException();
     }
-    DocCollection coll = fetchCachedCollection(collection);
-    if (coll != null && predicate.matches(liveNodes, coll)) return;
 
     final CountDownLatch latch = new CountDownLatch(1);
     waitLatches.add(latch);
@@ -1960,8 +1922,7 @@ public class ZkStateReader implements SolrCloseable {
     if (closed) {
       throw new AlreadyClosedException();
     }
-    DocCollection coll = fetchCachedCollection(collection);
-    if (coll != null && predicate.test(coll)) return coll;
+
     final CountDownLatch latch = new CountDownLatch(1);
     waitLatches.add(latch);
     AtomicReference<DocCollection> docCollection = new AtomicReference<>();
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java 
b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
index 22c14473f2c..cda0b66a9e6 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
@@ -391,14 +391,6 @@ public class ClusterState implements JSONWriter.Writable {
     protected final AtomicInteger gets = new AtomicInteger();
     private final DocCollection coll;
 
-    /**
-     * return the collection if it is already loaded. lazy references may 
return null if it is not
-     * loaded already
-     */
-    public DocCollection getOrNull() {
-      return coll;
-    }
-
     public int getCount() {
       return gets.get();
     }

Reply via email to