You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "psalagnac (via GitHub)" <gi...@apache.org> on 2024/11/04 14:40:39 UTC
Re: [PR] SOLR-17453: Leverage waitForState() instead of busy waiting [solr]
psalagnac commented on code in PR #2737:
URL: https://github.com/apache/solr/pull/2737#discussion_r1827843673
##########
solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java:
##########
@@ -221,24 +223,19 @@ public void call(ClusterState clusterState, ZkNodeProps message, NamedList<Objec
}
// wait for a while until we see the collection
- TimeOut waitUntil =
- new TimeOut(30, TimeUnit.SECONDS, ccc.getSolrCloudManager().getTimeSource());
- boolean created = false;
- while (!waitUntil.hasTimedOut()) {
- waitUntil.sleep(100);
- created = ccc.getSolrCloudManager().getClusterState().hasCollection(collectionName);
- if (created) break;
- }
- if (!created) {
+ try {
+ newColl =
+ zkStateReader.waitForState(collectionName, 30, TimeUnit.SECONDS, Objects::nonNull);
+ } catch (TimeoutException e) {
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR,
- "Could not fully create collection: " + collectionName);
+ "Could not fully create collection: " + collectionName,
+ e);
}
// refresh cluster state (value read below comes from Zookeeper watch firing following the
// update done previously, be it by Overseer or by this thread when updates are distributed)
clusterState = ccc.getSolrCloudManager().getClusterState();
- newColl = clusterState.getCollection(collectionName);
Review Comment:
`newColl` is assigned from result of `waitForState()`, line 227. We're sure we already have the latest available version.
It would be a dupe to get it again here.
--
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