SOLR-10588: Prevent redundant double core reload on config update.

This commit is contained in:
Mikhail Khludnev 2017-04-30 23:37:51 +03:00
parent b5e9b5aaf6
commit cbd3b02cda
3 changed files with 21 additions and 4 deletions

View File

@ -273,6 +273,8 @@ Bug Fixes
* SOLR-10316: Unloading a core can remove a ZK SolrCore registration entry for the wrong SolrCore. (Mark Miller)
* SOLR-10588: Prevent redundant core reload on config update (Mikhail Khludnev)
Other Changes
----------------------

View File

@ -100,6 +100,7 @@ import org.apache.solr.core.snapshots.SolrSnapshotMetaDataManager.SnapshotMetaDa
import org.apache.solr.handler.IndexFetcher;
import org.apache.solr.handler.ReplicationHandler;
import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.handler.SolrConfigHandler;
import org.apache.solr.handler.component.HighlightComponent;
import org.apache.solr.handler.component.SearchComponent;
import org.apache.solr.logging.MDCLoggingContext;
@ -2945,10 +2946,19 @@ public final class SolrCore implements SolrInfoBean, SolrMetricProducer, Closeab
checkStale(zkClient, solrConfigPath, overlayVersion) ||
checkStale(zkClient, managedSchmaResourcePath, managedSchemaVersion)) {
log.info("core reload {}", coreName);
try {
cc.reload(coreName);
} catch (SolrCoreState.CoreIsClosedException e) {
/*no problem this core is already closed*/
SolrConfigHandler configHandler = ((SolrConfigHandler)core.getRequestHandler("/config"));
if (configHandler.getReloadLock().tryLock()){
try {
cc.reload(coreName);
} catch (SolrCoreState.CoreIsClosedException e) {
/*no problem this core is already closed*/
} finally {
configHandler.getReloadLock().unlock();
}
} else {
log.info("Another reload is in progress. Not doing anything.");
}
return;
}

View File

@ -104,6 +104,11 @@ public class SolrConfigHandler extends RequestHandlerBase implements SolrCoreAwa
public static final boolean configEditing_disabled = Boolean.getBoolean(CONFIGSET_EDITING_DISABLED_ARG);
private static final Map<String, SolrConfig.SolrPluginInfo> namedPlugins;
private Lock reloadLock = new ReentrantLock(true);
public Lock getReloadLock() {
return reloadLock;
}
private boolean isImmutableConfigSet = false;
static {