You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2013/05/23 21:19:11 UTC
svn commit: r1485832 - in /lucene/dev/branches/branch_4x: ./ solr/
solr/core/ solr/core/src/java/org/apache/solr/cloud/
solr/core/src/java/org/apache/solr/core/
solr/core/src/java/org/apache/solr/handler/admin/
solr/core/src/test/org/apache/solr/cloud/
Author: markrmiller
Date: Thu May 23 19:19:11 2013
New Revision: 1485832
URL: http://svn.apache.org/r1485832
Log:
SOLR-4814: If a SolrCore cannot be created it should remove any information it published about itself from ZooKeeper.
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/Overseer.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/CoreContainer.java
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1485832&r1=1485831&r2=1485832&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Thu May 23 19:19:11 2013
@@ -81,6 +81,9 @@ Bug Fixes
* SOLR-4842: Fix facet.field local params from affecting other facet.field's.
(ehatcher, hossman)
+* SOLR-4814: If a SolrCore cannot be created it should remove any information it
+ published about itself from ZooKeeper. (Mark Miller)
+
Other Changes
----------------------
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/Overseer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/Overseer.java?rev=1485832&r1=1485831&r2=1485832&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/Overseer.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/Overseer.java Thu May 23 19:19:11 2013
@@ -537,6 +537,15 @@ public class Overseer {
DocCollection coll = newCollections.get(collection);
if (coll == null) {
// TODO: log/error that we didn't find it?
+ // just in case, remove the zk collection node
+ try {
+ zkClient.clean("/collections/" + collection);
+ } catch (InterruptedException e) {
+ SolrException.log(log, "Cleaning up collection in zk was interrupted:" + collection, e);
+ Thread.currentThread().interrupt();
+ } catch (KeeperException e) {
+ SolrException.log(log, "Problem cleaning up collection in zk:" + collection, e);
+ }
return clusterState;
}
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/CoreContainer.java?rev=1485832&r1=1485831&r2=1485832&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/CoreContainer.java Thu May 23 19:19:11 2013
@@ -426,6 +426,16 @@ public class CoreContainer
c = create(p);
registerCore(p.isTransient(), name, c, false);
} catch (Throwable t) {
+ if (isZooKeeperAware()) {
+ try {
+ zkSys.zkController.unregister(name, p);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ SolrException.log(log, null, e);
+ } catch (KeeperException e) {
+ SolrException.log(log, null, e);
+ }
+ }
SolrException.log(log, null, t);
if (c != null) {
c.close();
@@ -988,6 +998,19 @@ public class CoreContainer
core.open();
}
} catch(Exception ex){
+ // remains to be seen how transient cores and such
+ // will work in SolrCloud mode, but just to be future
+ // proof...
+ if (isZooKeeperAware()) {
+ try {
+ getZkController().unregister(name, desc);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ SolrException.log(log, null, e);
+ } catch (KeeperException e) {
+ SolrException.log(log, null, e);
+ }
+ }
throw recordAndThrow(name, "Unable to create core: " + name, ex);
} finally {
solrCores.removeFromPendingOps(name);
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java?rev=1485832&r1=1485831&r2=1485832&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java Thu May 23 19:19:11 2013
@@ -414,6 +414,7 @@ public class CoreAdminHandler extends Re
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Core name is mandatory to CREATE a SolrCore");
}
+ CoreDescriptor dcore = null;
try {
if (coreContainer.getAllCoreNames().contains(name)) {
@@ -428,7 +429,7 @@ public class CoreAdminHandler extends Re
instanceDir = name; // bare name is already relative to solr home
}
- CoreDescriptor dcore = new CoreDescriptor(coreContainer, name, instanceDir);
+ dcore = new CoreDescriptor(coreContainer, name, instanceDir);
// fillup optional parameters
String opts = params.get(CoreAdminParams.CONFIG);
@@ -511,6 +512,16 @@ public class CoreAdminHandler extends Re
rsp.add("core", core.getName());
return coreContainer.isPersistent();
} catch (Exception ex) {
+ if (coreContainer.isZooKeeperAware() && dcore != null) {
+ try {
+ coreContainer.getZkController().unregister(name, dcore);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ SolrException.log(log, null, e);
+ } catch (KeeperException e) {
+ SolrException.log(log, null, e);
+ }
+ }
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
"Error CREATEing SolrCore '" + name + "': " +
ex.getMessage(), ex);
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=1485832&r1=1485831&r2=1485832&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java Thu May 23 19:19:11 2013
@@ -333,12 +333,44 @@ public class BasicDistributedZkTest exte
testUpdateProcessorsRunOnlyOnce("distrib-dup-test-chain-implicit");
testStopAndStartCoresInOneInstance();
+ testFailedCoreCreateCleansUp();
// Thread.sleep(10000000000L);
if (DEBUG) {
super.printLayout();
}
}
+ private void testFailedCoreCreateCleansUp() throws Exception {
+ Create createCmd = new Create();
+ createCmd.setCoreName("core1");
+ createCmd.setCollection("the_core_collection");
+ String coredataDir = dataDir.getAbsolutePath() + File.separator
+ + System.currentTimeMillis() + "the_core_collection";
+ createCmd.setDataDir(coredataDir);
+ createCmd.setNumShards(1);
+ createCmd.setSchemaName("nonexistent_schema.xml");
+
+ String url = getBaseUrl(clients.get(0));
+ final HttpSolrServer server = new HttpSolrServer(url);
+ try {
+ server.request(createCmd);
+ fail("Expected SolrCore create to fail");
+ } catch (Exception e) {
+
+ }
+
+ long timeout = System.currentTimeMillis() + 15000;
+ while (cloudClient.getZkStateReader().getZkClient().exists("/collections/the_core_collection", true)) {
+ if (timeout <= System.currentTimeMillis()) {
+ fail(cloudClient.getZkStateReader().getZkClient().getChildren("/collections", null, true).toString() + " Collection zk node still exists");
+ }
+ Thread.sleep(100);
+ }
+
+
+ assertFalse("Collection zk node still exists", cloudClient.getZkStateReader().getZkClient().exists("/collections/the_core_collection", true));
+ }
+
private void testShardParamVariations() throws Exception {
SolrQuery query = new SolrQuery("*:*");
Map<String,Long> shardCounts = new HashMap<String,Long>();