You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by no...@apache.org on 2023/07/24 11:03:49 UTC
[solr] branch branch_9x updated: SOLR-16871: Synchronize on a larger block to avoid race condition in CoordinatorHttpSolrCall init (#1800)
This is an automated email from the ASF dual-hosted git repository.
noble pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 848f1b04165 SOLR-16871: Synchronize on a larger block to avoid race condition in CoordinatorHttpSolrCall init (#1800)
848f1b04165 is described below
commit 848f1b04165bdb7e84c811b571a65719a0e3bb2c
Author: patsonluk <pa...@users.noreply.github.com>
AuthorDate: Mon Jul 24 04:02:11 2023 -0700
SOLR-16871: Synchronize on a larger block to avoid race condition in CoordinatorHttpSolrCall init (#1800)
* Synchronize to avoid race condition in CoordinatorHttpSolrCall
* ./gradlew tidy
---
.../solr/servlet/CoordinatorHttpSolrCall.java | 64 ++++++++++++----------
1 file changed, 34 insertions(+), 30 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java
index cadb5a735c5..82664b23623 100644
--- a/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java
+++ b/solr/core/src/java/org/apache/solr/servlet/CoordinatorHttpSolrCall.java
@@ -91,40 +91,44 @@ public class CoordinatorHttpSolrCall extends HttpSolrCall {
String syntheticCollectionName = getSyntheticCollectionName(confName);
DocCollection syntheticColl = clusterState.getCollectionOrNull(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);
- }
+ 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);
+ }
- 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);