You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2022/08/29 21:30:23 UTC
[solr] branch branch_9x updated: SOLR-16353: New solr.shardSplit.checkDiskSpace.enabled setting (#983)
This is an automated email from the ASF dual-hosted git repository.
dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 816e204d68b SOLR-16353: New solr.shardSplit.checkDiskSpace.enabled setting (#983)
816e204d68b is described below
commit 816e204d68bbe6f5653c5b39bdc7e9354a4279e9
Author: Haythem <ha...@yahoo.fr>
AuthorDate: Mon Aug 29 22:24:10 2022 +0200
SOLR-16353: New solr.shardSplit.checkDiskSpace.enabled setting (#983)
And make checkDiskSpace tolerant to an absence of metrics information in case it's not present for whatever reason (e.g. transient core).
HdfsDirectory will now not do checkDiskSpace.
Co-authored-by: David Smiley <ds...@salesforce.com>
---
solr/CHANGES.txt | 4 ++++
.../solr/cloud/api/collections/SplitShardCmd.java | 27 ++++++++++++----------
.../org/apache/solr/hdfs/HdfsDirectoryFactory.java | 5 ++++
.../apache/solr/hdfs/HdfsDirectoryFactoryTest.java | 5 ++++
.../deployment-guide/pages/shard-management.adoc | 6 +++++
5 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 701af2e889d..a964f835eeb 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -46,6 +46,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.java
index 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 fail
NodeStateProvider 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 leader
List<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 LINK
double 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.java
index 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 CachingDirectoryFactory
if (kerberosEnabled) {
initKerberos();
}
+ if (StringUtils.isEmpty(System.getProperty(SplitShardCmd.SHARDSPLIT_CHECKDISKSPACE_ENABLED))) {
+ System.setProperty(SplitShardCmd.SHARDSPLIT_CHECKDISKSPACE_ENABLED, "false");
+ }
}
@Override
diff --git a/solr/modules/hdfs/src/test/org/apache/solr/hdfs/HdfsDirectoryFactoryTest.java b/solr/modules/hdfs/src/test/org/apache/solr/hdfs/HdfsDirectoryFactoryTest.java
index 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.adoc
index 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, which
For 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