From 45526e27d29878c5a24e7a83ac995b57d5f1c457 Mon Sep 17 00:00:00 2001 From: David Smiley Date: Tue, 4 Aug 2026 09:25:42 -0400 Subject: [PATCH] SOLR-18334: PRS collection creation returns too early --can cause restore failure. As seen by some flaky tests. --- .../SOLR-18334-prs-creation-waitForState.yml | 8 ++++++++ .../cloud/api/collections/CreateCollectionCmd.java | 11 +++++++++++ 2 files changed, 19 insertions(+) create mode 100644 changelog/unreleased/SOLR-18334-prs-creation-waitForState.yml 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 000000000000..df7a1d93660a --- /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 dd6fdf2da633..14291d7b9411 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 @@ -204,6 +204,17 @@ public void call(AdminCmdContext adminCmdContext, ZkNodeProps message, NamedList 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