You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "noblepaul (via GitHub)" <gi...@apache.org> on 2023/01/30 19:06:21 UTC

[GitHub] [solr] noblepaul commented on a diff in pull request #1318: SOLR-16636: ZkStateReader.waitForState should not register a watch if state already matches predicate

noblepaul commented on code in PR #1318:
URL: https://github.com/apache/solr/pull/1318#discussion_r1091033787


##########
solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/ZkStateReader.java:
##########
@@ -1682,6 +1687,37 @@ public DocCollection getCollectionLive(String coll) {
     }
   }
 
+  /**
+   * 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));
+      }

Review Comment:
   actually, there is another PR that is waiting to be merged #1242 . that ensures that the this update is in-place. 
   
   I'm waiting for perf tests to come back to merge that



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org