This is an automated email from the ASF dual-hosted git repository. dsmiley pushed a commit to branch branch_9x in repository https://gitbox.apache.org/repos/asf/solr.git
commit e594760f947930c6d492c3ad1c593d7f9dc3e3cc Author: David Smiley <[email protected]> AuthorDate: Sun Aug 9 23:08:24 2026 -0400 SOLR-18334: PRS collection creation returns too early (#4704) Consequence: the caller might try to do something with it immediately after that results in a failure. A test sometimes showed this issue with backup-restore. (cherry picked from commit 22c1a9fd344ba52c017a90dc7960f171c0f93dac) (cherry picked from commit 26cbbe7858a9575140f7a5226b94ba16e5fc47af) --- changelog/unreleased/SOLR-18334-prs-creation-waitForState.yml | 8 ++++++++ .../solr/cloud/api/collections/CreateCollectionCmd.java | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/changelog/unreleased/SOLR-18334-prs-creation-waitForState.yml b/changelog/unreleased/SOLR-18334-prs-creation-waitForState.yml new file mode 100644 index 00000000000..df7a1d93660 --- /dev/null +++ b/changelog/unreleased/SOLR-18334-prs-creation-waitForState.yml @@ -0,0 +1,8 @@ +title: > + PRS based collection creation returns too early; can cause restore failure. +type: fixed +authors: + - name: David Smiley +links: + - name: SOLR-18334 + url: https://issues.apache.org/jira/browse/SOLR-18334 diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java index b2b2f7a722b..63c5a009896 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java @@ -198,6 +198,17 @@ public class CreateCollectionCmd implements CollApiCmds.CollectionApiCommand { clusterState = clusterState.copyWith(collectionName, command.collection); newColl = command.collection; ccc.submitIntraProcessMessage(new RefreshCollectionMessage(collectionName)); + + // ensure the local ZkStateReader sees the collection before returning, so callers get the + // same "collection exists" guarantee as the non-PRS path + try { + zkStateReader.waitForState(collectionName, 30, TimeUnit.SECONDS, Objects::nonNull); + } catch (TimeoutException e) { + throw new SolrException( + SolrException.ErrorCode.SERVER_ERROR, + "Could not fully create collection: " + collectionName, + e); + } } else { if (ccc.getDistributedClusterStateUpdater().isDistributedStateUpdate()) { // The message has been crafted by CollectionsHandler.CollectionOperation.CREATE_OP and
