muse-dev[bot] commented on a change in pull request #2049:
URL: https://github.com/apache/lucene-solr/pull/2049#discussion_r514854533



##########
File path: solr/core/src/java/org/apache/solr/core/CoreContainer.java
##########
@@ -1253,77 +1254,90 @@ public SolrCore create(String coreName, Map<String, 
String> parameters) {
    * @return the newly created core
    */
   public SolrCore create(String coreName, Path instancePath, Map<String, 
String> parameters, boolean newCollection) {
-
-    CoreDescriptor cd = new CoreDescriptor(coreName, instancePath, parameters, 
getContainerProperties(), getZkController());
-
-    // TODO: There's a race here, isn't there?
-    // Since the core descriptor is removed when a core is unloaded, it should 
never be anywhere when a core is created.
-    if (getAllCoreNames().contains(coreName)) {
-      log.warn("Creating a core with existing name is not allowed");
-      // TODO: Shouldn't this be a BAD_REQUEST?
-      throw new SolrException(ErrorCode.SERVER_ERROR, "Core with name '" + 
coreName + "' already exists.");
-    }
-
-    // Validate paths are relative to known locations to avoid path traversal
-    assertPathAllowed(cd.getInstanceDir());
-    assertPathAllowed(Paths.get(cd.getDataDir()));
-
-    boolean preExisitingZkEntry = false;
     try {
-      if (getZkController() != null) {
-        if (cd.getCloudDescriptor().getCoreNodeName() == null) {
-          throw new SolrException(ErrorCode.SERVER_ERROR, "coreNodeName 
missing " + parameters.toString());
+      synchronized (inFlightCreations) {
+        if (inFlightCreations.contains(coreName)) {
+          String msg = "Already creating a core with name '" + coreName + "', 
call aborted '";
+          log.warn(msg);
+          throw new SolrException(ErrorCode.SERVER_ERROR, msg);
         }
-        preExisitingZkEntry = 
getZkController().checkIfCoreNodeNameAlreadyExists(cd);
+        inFlightCreations.add(coreName);
+      }
+      CoreDescriptor cd = new CoreDescriptor(coreName, instancePath, 
parameters, getContainerProperties(), getZkController());

Review comment:
       *THREAD_SAFETY_VIOLATION:*  Read/Write race. Non-private method 
`CoreContainer.create(...)` indirectly reads without synchronization from 
`this.zkSys.zkController`. Potentially races with write in method 
`CoreContainer.load()`.
    Reporting because this access may occur on a background thread.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to