diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java index 2d545bac95..ec2b8b64a0 100644 --- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java @@ -1196,6 +1196,17 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw TimeUnit.MILLISECONDS.convert(pollIntervalNs, TimeUnit.NANOSECONDS)); } + private static Integer getReserveCommitDuration(NamedList nl, Integer reserveCommitDuration) + { + if (nl != null) { + String reserve = (String) nl.get(RESERVE); + if (reserve != null && !reserve.trim().equals("")) { + return readIntervalMs(reserve); + } + } + return reserveCommitDuration; + } + @Override @SuppressWarnings("unchecked") public void inform(SolrCore core) { @@ -1216,9 +1227,10 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw } NamedList master = (NamedList) initArgs.get("master"); boolean enableMaster = isEnabled( master ); - + final boolean solrCloudEnabled = (core.getCoreContainer().getZkController() != null); + if (enableMaster || (enableSlave && !currentIndexFetcher.fetchFromLeader)) { - if (core.getCoreContainer().getZkController() != null) { + if (solrCloudEnabled) { LOG.warn("SolrCloud is enabled for core " + core.getName() + " but so is old-style replication. Make sure you" + " intend this behavior, it usually indicates a mis-configuration. Master setting is " + Boolean.toString(enableMaster) + " and slave setting is " + Boolean.toString(enableSlave)); @@ -1302,7 +1314,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw ***/ } } - + // ensure the writer is init'd so that we have a list of commit points RefCounted iw = core.getUpdateHandler().getSolrCoreState().getIndexWriter(core); iw.decref(); @@ -1313,13 +1325,14 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw if (s!=null) s.decref(); } } - String reserve = (String) master.get(RESERVE); - if (reserve != null && !reserve.trim().equals("")) { - reserveCommitDuration = readIntervalMs(reserve); - } - LOG.info("Commits will be reserved for " + reserveCommitDuration); + reserveCommitDuration = getReserveCommitDuration(master, reserveCommitDuration); // Deprecated isMaster = true; } + + if (enableMaster || solrCloudEnabled) { + reserveCommitDuration = getReserveCommitDuration(initArgs, reserveCommitDuration); + LOG.info("Commits will be reserved for " + reserveCommitDuration + "ms."); + } } // check master or slave is enabled diff --git a/solr/solr-ref-guide/src/index-replication.adoc b/solr/solr-ref-guide/src/index-replication.adoc index 774b78cde7..a612d6c7fb 100644 --- a/solr/solr-ref-guide/src/index-replication.adoc +++ b/solr/solr-ref-guide/src/index-replication.adoc @@ -86,6 +86,7 @@ In addition to `ReplicationHandler` configuration options specific to the master * `maxNumberOfBackups` an integer value dictating the maximum number of backups this node will keep on disk as it receives `backup` commands. * Similar to most other request handlers in Solr you may configure a set of <> parameters corresponding with any request parameters supported by the `ReplicationHandler` when <>. +* `commitReserveDuration` If IndexFetcher fails and then restarts from scratch because an index file was deleted before it could be fetched, you can tweak this parameter to increase the retention time of index files. The default is 10 seconds. [[IndexReplication-ConfiguringtheReplicationRequestHandleronaMasterServer]] === Configuring the Replication RequestHandler on a Master Server