Skip to content

Commit

Permalink
SOLR-16871: Fix for duplicated replica added from first coordinator n…
Browse files Browse the repository at this point in the history
…ode (apache#1794)
  • Loading branch information
patsonluk authored and Justin Sweeney committed Apr 26, 2024
1 parent 4e057d6 commit 433661e
Showing 1 changed file with 30 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,44 +91,40 @@ public static SolrCore getCore(
String syntheticCollectionName = getSyntheticCollectionName(confName);

DocCollection syntheticColl = clusterState.getCollectionOrNull(syntheticCollectionName);
synchronized (CoordinatorHttpSolrCall.class) {
if (syntheticColl == null) {
// no synthetic collection for this config, let's create one
if (log.isInfoEnabled()) {
log.info(
"synthetic collection: {} does not exist, creating.. ", syntheticCollectionName);
}
if (syntheticColl == null) {
// no synthetic collection for this config, let's create one
if (log.isInfoEnabled()) {
log.info(
"synthetic collection: {} does not exist, creating.. ", syntheticCollectionName);
}

SolrException createException = null;
try {
createColl(syntheticCollectionName, solrCall.cores, confName);
} catch (SolrException exception) {
// concurrent requests could have created the collection hence causing collection
// exists
// exception
createException = exception;
} finally {
syntheticColl =
zkStateReader.getClusterState().getCollectionOrNull(syntheticCollectionName);
}
SolrException createException = null;
try {
createColl(syntheticCollectionName, solrCall.cores, confName);
} catch (SolrException exception) {
// concurrent requests could have created the collection hence causing collection exists
// exception
createException = exception;
} finally {
syntheticColl =
zkStateReader.getClusterState().getCollectionOrNull(syntheticCollectionName);
}

// then indeed the collection was not created properly, either by this or other
// concurrent
// requests
if (syntheticColl == null) {
if (createException != null) {
throw createException; // rethrow the exception since such collection was not
// created
} else {
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR,
"Could not locate synthetic collection ["
+ syntheticCollectionName
+ "] after creation!");
}
// then indeed the collection was not created properly, either by this or other concurrent
// requests
if (syntheticColl == null) {
if (createException != null) {
throw createException; // rethrow the exception since such collection was not created
} else {
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR,
"Could not locate synthetic collection ["
+ syntheticCollectionName
+ "] after creation!");
}
}

}
synchronized (CoordinatorHttpSolrCall.class) {
// get docCollection again to ensure we get the fresh state
syntheticColl =
zkStateReader.getClusterState().getCollectionOrNull(syntheticCollectionName);
Expand Down

0 comments on commit 433661e

Please sign in to comment.