This is an automated email from the ASF dual-hosted git repository.

mdrob pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new dfef340  SOLR-15918 Fix test failures (#568)
dfef340 is described below

commit dfef340534c507dbc11f3c4f4254d32dcc4f67bf
Author: Mike Drob <[email protected]>
AuthorDate: Wed Jan 26 17:44:07 2022 -0600

    SOLR-15918 Fix test failures (#568)
---
 .../src/java/org/apache/solr/common/cloud/SolrZkClient.java   |  2 ++
 .../java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java | 11 +++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java 
b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
index 7a45c36..1006dca 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
@@ -499,6 +499,8 @@ public class SolrZkClient implements Closeable {
    *
    * Note: retryOnConnLoss is only respected for the final node - nodes
    * before that are always retried on connection loss.
+   *
+   * Note: if failOnExists == false then we will always overwrite the existing 
data with the given data
    */
   public void makePath(String path, byte[] data, CreateMode createMode,
       Watcher watcher, boolean failOnExists, boolean retryOnConnLoss, int 
skipPathParts) throws KeeperException, InterruptedException {
diff --git 
a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java 
b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
index 03a74aa..decb831 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
@@ -298,6 +298,9 @@ public class ZkMaintenanceUtils {
           // if the path exists (and presumably we're uploading data to it) 
just set its data
           if (file.toFile().getName().equals(ZKNODE_DATA_FILE) && 
zkClient.exists(zkNode, true)) {
             zkClient.setData(zkNode, file, true);
+          } else if (file == rootPath) {
+            // We are only uploading a single file, preVisitDirectory was 
never called
+            zkClient.makePath(zkNode, file, false, true);
           } else {
             // Skip path parts here because they should have been created 
during preVisitDirectory
             int pathParts = file.getNameCount() + partsOffset;
@@ -318,12 +321,16 @@ public class ZkMaintenanceUtils {
         try {
           if (dir.equals(rootPath)) {
             // Make sure the root path exists, including potential parents
-            zkClient.makePath(zkNode, false, true);
+            zkClient.makePath(zkNode, true);
           } else {
             // Skip path parts here because they should have been created 
during previous visits
             int pathParts = dir.getNameCount() + partsOffset;
-            zkClient.makePath(zkNode, null, CreateMode.PERSISTENT, null, 
false, true, pathParts);
+            zkClient.makePath(zkNode, null, CreateMode.PERSISTENT, null, true, 
true, pathParts);
           }
+        } catch (KeeperException.NodeExistsException ignored) {
+          // Using fail-on-exists == false has side effect of makePath 
attempting to setData on the leaf of the path
+          // We prefer that if the parent directory already exists, we do not 
modify it
+          // Particularly relevant for marking config sets as trusted
         } catch (KeeperException | InterruptedException e) {
           throw new IOException("Error creating intermediate directory " + dir,
               SolrZkClient.checkInterrupted(e));

Reply via email to