Skip to content

Apache Lucene open-source search software

* SOLR-4003: The SolrZKClient clean method should not try and clear zk paths that start with /zookeeper, as this can fail and stop the removal of further nodes. (Mark Miller)

Mark Robert Miller27181e53a086
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 26a6cdd11df..0d6b8eb4785 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -182,6 +182,9 @@ Bug Fixes
* SOLR-4036: field aliases in fl should not cause properties of target field
to be used. (Martin Koch, yonik)
+* SOLR-4003: The SolrZKClient clean method should not try and clear zk paths
+ that start with /zookeeper, as this can fail and stop the removal of
+ further nodes. (Mark Miller)
Other Changes
----------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
index 883f0833c99..9e0e8c71481 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
@@ -71,6 +71,32 @@ public class ZkSolrClientTest extends AbstractSolrTestCase {
zkClient.close();
server.shutdown();
}
+
+ public void testClean() throws Exception {
+ String zkDir = dataDir.getAbsolutePath() + File.separator
+ + "zookeeper/server1/data";
+ ZkTestServer server = null;
+
+ server = new ZkTestServer(zkDir);
+ server.run();
+ AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
+
+
+ SolrZkClient zkClient = new SolrZkClient(server.getZkHost(),
+ AbstractZkTestCase.TIMEOUT);
+
+ zkClient.makePath("/test/path/here", true);
+
+ zkClient.makePath("/zz/path/here", true);
+
+ zkClient.clean("/");
+
+ assertFalse(zkClient.exists("/test", true));
+ assertFalse(zkClient.exists("/zz", true));
+
+ zkClient.close();
+ server.shutdown();
+ }
public void testReconnect() throws Exception {
String zkDir = dataDir.getAbsolutePath() + File.separator
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 0cc59a96a60..2cd6eabebe5 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
@@ -590,6 +590,8 @@ public class SolrZkClient {
return;
}
for (String string : children) {
+ // we can't clean the built-in zookeeper node
+ if (path.equals("/") && string.equals("zookeeper")) continue;
if (path.equals("/")) {
clean(path + string);
} else {