nick-boss-tech commented on code in PR #5314:
URL: https://github.com/apache/solr/pull/5314#discussion_r4570133840


##########
solr/solrj-zookeeper/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java:
##########
@@ -80,12 +80,39 @@ public ZkClientClusterStateProvider(String zkHost) {
 
   @Override
   public ClusterState.CollectionRef getState(String collection) {
-    ClusterState clusterState = getZkStateReader().getClusterState();
-    if (clusterState != null) {
-      return clusterState.getCollectionRef(collection);
-    } else {
+    ZkStateReader reader = getZkStateReader();
+    ClusterState clusterState = reader.getClusterState();
+    if (clusterState == null) {
       return null;
     }
+    ClusterState.CollectionRef ref = clusterState.getCollectionRef(collection);
+    // Alias names are probed as collections before they are resolved. Avoid a 
ZooKeeper
+    // lookup for a known alias on every request.
+    if (ref != null || reader.getAliases().hasAlias(collection)) {
+      return ref;
+    }
+
+    try {
+      // Curator sync is asynchronous; wait for it before reading a missing 
collection.
+      reader.getZkClient().sync(ZkStateReader.COLLECTIONS_ZKNODE);

Review Comment:
   🤖 *AI text below* 🤖 *(reviewed by Nick Shanin)*
   
   I agree that sync belongs in `forceUpdateCollection`. I removed sync and 
`SolrZkClient.sync()` from this PR. The separate change calls sync before the 
collection read, outside the state update lock. Without sync, this PR cannot 
guarantee that a lagging ZooKeeper server has caught up. I have not opened the 
separate PR yet.
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to