From 8cc978b53b1299a27de492d7114cd2d4e353b6cb Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Fri, 11 Mar 2016 00:49:49 +0530 Subject: [PATCH] SOLR-8135: SolrCloudExampleTest.testLoadDocsIntoGettingStartedCollection reproducible failure --- .../src/java/org/apache/solr/core/CoreContainer.java | 6 ++++-- solr/core/src/java/org/apache/solr/core/SolrCore.java | 10 +++++++--- .../src/java/org/apache/solr/update/SolrCoreState.java | 8 +++++++- .../org/apache/solr/cloud/SolrCloudExampleTest.java | 1 - 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java index 1d614e343dc..c140fb4dba8 100644 --- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java +++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java @@ -62,6 +62,7 @@ import org.apache.solr.security.AuthorizationPlugin; import org.apache.solr.security.HttpClientInterceptorPlugin; import org.apache.solr.security.PKIAuthenticationPlugin; import org.apache.solr.security.SecurityPluginHolder; +import org.apache.solr.update.SolrCoreState; import org.apache.solr.update.UpdateShardHandler; import org.apache.solr.util.DefaultSolrThreadFactory; import org.apache.zookeeper.KeeperException; @@ -916,8 +917,9 @@ public class CoreContainer { log.info("Reloading SolrCore '{}' using configuration from {}", cd.getName(), coreConfig.getName()); SolrCore newCore = core.reload(coreConfig); registerCore(name, newCore, false); - } - catch (Exception e) { + } catch (SolrCoreState.CoreIsClosedException e) { + throw e; + } catch (Exception e) { coreInitFailures.put(cd.getName(), new CoreLoadFailure(cd, e)); throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to reload core [" + cd.getName() + "]", e); } diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java index cde878a5ebf..7a65a72decb 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrCore.java +++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java @@ -534,8 +534,8 @@ public final class SolrCore implements SolrInfoMBean, Closeable { // Create the index if it doesn't exist. if(!indexExists) { - log.warn(logid+"Solr index directory '" + new File(indexDir) + "' doesn't exist." - + " Creating new index..."); + log.warn(logid + "Solr index directory '" + new File(indexDir) + "' doesn't exist." + + " Creating new index..."); SolrIndexWriter writer = SolrIndexWriter.create(this, "SolrCore.initIndex", indexDir, getDirectoryFactory(), true, getLatestSchema(), solrConfig.indexConfig, solrDelPolicy, codec); @@ -2501,7 +2501,11 @@ public final class SolrCore implements SolrInfoMBean, Closeable { checkStale(zkClient, solrConfigPath, overlayVersion) || checkStale(zkClient, managedSchmaResourcePath, managedSchemaVersion)) { log.info("core reload {}", coreName); - cc.reload(coreName); + try { + cc.reload(coreName); + } catch (SolrCoreState.CoreIsClosedException e) { + /*no problem this core is already closed*/ + } return; } //some files in conf directory may have other than managedschema, overlay, params diff --git a/solr/core/src/java/org/apache/solr/update/SolrCoreState.java b/solr/core/src/java/org/apache/solr/update/SolrCoreState.java index 42727b4a64a..fc0bca8a125 100644 --- a/solr/core/src/java/org/apache/solr/update/SolrCoreState.java +++ b/solr/core/src/java/org/apache/solr/update/SolrCoreState.java @@ -51,7 +51,7 @@ public abstract class SolrCoreState { public void increfSolrCoreState() { synchronized (this) { if (solrCoreStateRefCnt == 0) { - throw new IllegalStateException("IndexWriter has been closed"); + throw new CoreIsClosedException("IndexWriter has been closed"); } solrCoreStateRefCnt++; } @@ -157,4 +157,10 @@ public abstract class SolrCoreState { public abstract boolean getLastReplicateIndexSuccess(); public abstract void setLastReplicateIndexSuccess(boolean success); + + public static class CoreIsClosedException extends IllegalStateException { + public CoreIsClosedException(String s) { + super(s); + } + } } diff --git a/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java b/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java index e889d90b3c7..f084c207345 100644 --- a/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/SolrCloudExampleTest.java @@ -43,7 +43,6 @@ import org.slf4j.LoggerFactory; * this test is useful for catching regressions in indexing the example docs in collections that * use data-driven schema and managed schema features provided by configsets/data_driven_schema_configs. */ -@LuceneTestCase.BadApple(bugUrl = "https://issues.apache.org/jira/browse/SOLR-8135") public class SolrCloudExampleTest extends AbstractFullDistribZkTestBase { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());