Apache Solr open-source search software
SOLR-16353: New solr.shardSplit.checkDiskSpace.enabled setting (#983)
Haythem2a6518021e56
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex a5a5f191236..553a7816b66 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -68,6 +68,10 @@ Improvements* SOLR-16323: The Docker image now uses the Solr User ID instead of the User Name, helps with non-root checks (Houston Putman)* SOLR-16337: implement Zk metrics (noble)++* SOLR-16353: Make SplitShardCmd#checkDiskSpace disableable through a system property. (Haythem Khiri)++Optimizations---------------------* SOLR-16120: Optimise hl.fl expansion. (Christine Poerschke, David Smiley, Mike Drob)diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.javaindex 89386e0ca99..7f78286cdab 100644--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java@@ -87,6 +87,9 @@ public class SplitShardCmd implements CollApiCmds.CollectionApiCommand {private static final int MAX_NUM_SUB_SHARDS = 8;private static final int DEFAULT_NUM_SUB_SHARDS = 2;+ public static final String SHARDSPLIT_CHECKDISKSPACE_ENABLED =+ "solr.shardSplit.checkDiskSpace.enabled";+private final CollectionCommandContext ccc;public SplitShardCmd(CollectionCommandContext ccc) {@@ -811,6 +814,10 @@ public class SplitShardCmd implements CollApiCmds.CollectionApiCommand {SolrIndexSplitter.SplitMethod method,SolrCloudManager cloudManager)throws SolrException {+ // check that the system property is enabled. It should not be disabled by default.+ if (!Boolean.parseBoolean(System.getProperty(SHARDSPLIT_CHECKDISKSPACE_ENABLED, "true"))) {+ return;+ }// check that enough disk space is available on the parent leader node// otherwise the actual index splitting will always failNodeStateProvider nodeStateProvider = cloudManager.getNodeStateProvider();@@ -821,9 +828,8 @@ public class SplitShardCmd implements CollApiCmds.CollectionApiCommand {nodeStateProvider.getReplicaInfo(parentShardLeader.getNodeName(), Collections.singletonList(CORE_IDX.metricsAttribute));if (infos.get(collection) == null || infos.get(collection).get(shard) == null) {- throw new SolrException(- SolrException.ErrorCode.SERVER_ERROR,- "missing replica information for parent shard leader");+ log.warn("cannot verify information for parent shard leader");+ return;}// find the leaderList<Replica> lst = infos.get(collection).get(shard);@@ -832,24 +838,21 @@ public class SplitShardCmd implements CollApiCmds.CollectionApiCommand {if (info.getCoreName().equals(parentShardLeader.getCoreName())) {Number size = (Number) info.get(CORE_IDX.metricsAttribute);if (size == null) {- throw new SolrException(- SolrException.ErrorCode.SERVER_ERROR,- "missing index size information for parent shard leader");+ log.warn("cannot verify information for parent shard leader");+ return;}indexSize = (Double) CORE_IDX.convertVal(size);break;}}if (indexSize == null) {- throw new SolrException(- SolrException.ErrorCode.SERVER_ERROR,- "missing replica information for parent shard leader");+ log.warn("missing replica information for parent shard leader");+ return;}Number freeSize = (Number) nodeValues.get(ImplicitSnitch.DISK);if (freeSize == null) {- throw new SolrException(- SolrException.ErrorCode.SERVER_ERROR,- "missing node disk space information for parent shard leader");+ log.warn("missing node disk space information for parent shard leader");+ return;}// 100% more for REWRITE, 5% more for LINKdouble neededSpace =diff --git a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.javaindex 9d32e5fef4b..0454a113d56 100644--- a/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java+++ b/solr/modules/hdfs/src/java/org/apache/solr/hdfs/HdfsDirectoryFactory.java@@ -49,8 +49,10 @@ import org.apache.lucene.store.NRTCachingDirectory;import org.apache.lucene.store.NoLockFactory;import org.apache.lucene.store.SingleInstanceLockFactory;import org.apache.solr.cloud.ZkController;+import org.apache.solr.cloud.api.collections.SplitShardCmd;import org.apache.solr.common.SolrException;import org.apache.solr.common.SolrException.ErrorCode;+import org.apache.solr.common.StringUtils;import org.apache.solr.common.params.SolrParams;import org.apache.solr.common.util.IOUtils;import org.apache.solr.common.util.NamedList;@@ -191,6 +193,9 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactoryif (kerberosEnabled) {initKerberos();}+ if (StringUtils.isEmpty(System.getProperty(SplitShardCmd.SHARDSPLIT_CHECKDISKSPACE_ENABLED))) {+ System.setProperty(SplitShardCmd.SHARDSPLIT_CHECKDISKSPACE_ENABLED, "false");+ }}@Overridediff --git a/solr/modules/hdfs/src/test/org/apache/solr/hdfs/HdfsDirectoryFactoryTest.java b/solr/modules/hdfs/src/test/org/apache/solr/hdfs/HdfsDirectoryFactoryTest.javaindex b5517c70f12..3c0ff3cb293 100644--- a/solr/modules/hdfs/src/test/org/apache/solr/hdfs/HdfsDirectoryFactoryTest.java+++ b/solr/modules/hdfs/src/test/org/apache/solr/hdfs/HdfsDirectoryFactoryTest.java@@ -38,6 +38,7 @@ import org.apache.lucene.tests.util.QuickPatchThreadsFilter;import org.apache.lucene.tests.util.TestUtil;import org.apache.solr.SolrIgnoredThreadsFilter;import org.apache.solr.SolrTestCaseJ4;+import org.apache.solr.cloud.api.collections.SplitShardCmd;import org.apache.solr.common.util.NamedList;import org.apache.solr.core.DirectoryFactory.DirContext;import org.apache.solr.handler.SnapShooter;@@ -74,6 +75,7 @@ public class HdfsDirectoryFactoryTest extends SolrTestCaseJ4 {HdfsTestUtil.teardownClass(dfsCluster);} finally {dfsCluster = null;+ System.clearProperty(SplitShardCmd.SHARDSPLIT_CHECKDISKSPACE_ENABLED);System.clearProperty(HdfsDirectoryFactory.HDFS_HOME);System.clearProperty(HdfsDirectoryFactory.CONFIG_DIRECTORY);System.clearProperty(HdfsDirectoryFactory.BLOCKCACHE_ENABLED);@@ -93,6 +95,9 @@ public class HdfsDirectoryFactoryTest extends SolrTestCaseJ4 {String dataHome = hdfsFactory.getDataHome(new MockCoreDescriptor());assertTrue(dataHome.endsWith("/solr1/mock/data"));+ assertFalse(+ Boolean.parseBoolean(+ System.getProperty(SplitShardCmd.SHARDSPLIT_CHECKDISKSPACE_ENABLED)));System.clearProperty(HdfsDirectoryFactory.HDFS_HOME);diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/shard-management.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/shard-management.adocindex 798c5624956..d2995f014d5 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/shard-management.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/shard-management.adoc@@ -274,6 +274,12 @@ The output will include the status of the request and the new shard names, whichFor example, "shard1" will become "shard1_0" and "shard1_1".If the status is anything other than "success", an error message will explain why the request failed.+=== Miscellaneous Configuration++When splitting a shard, a free disk space check is performed on the local file system of the leader shard.+This can be disabled through the `solr.shardSplit.checkDiskSpace.enabled` system property (i.e. `-Dsolr.shardSplit.checkDiskSpace.enabled=false`).+It is already disabled by default for xref:solr-on-hdfs.adoc[HDFS].+[[createshard]]== CREATESHARD: Create a Shard