From f3cb93a1e346b0128161b66180acff986f5d5f3d Mon Sep 17 00:00:00 2001 From: Stef Nestor <26751266+stefnestor@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:54:06 -0600 Subject: [PATCH 1/8] (Err>Doc) Max Shards Per Node --- .../org/elasticsearch/cluster/shards/ClusterShardLimitIT.java | 4 +++- .../src/main/java/org/elasticsearch/common/ReferenceDocs.java | 1 + .../org/elasticsearch/common/reference-docs-links.json | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java index 3202f5513e9ac..a2415ec3d74ca 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java @@ -17,6 +17,7 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.common.Priority; +import org.elasticsearch.common.ReferenceDocs; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.index.IndexVersion; @@ -152,7 +153,8 @@ public void testIncreaseReplicasOverLimit() { + firstShardCount + "]/[" + dataNodes * shardsPerNode - + "] maximum normal shards open;"; + + "] maximum normal shards open; for more information see " + + ReferenceDocs.MAX_SHARDS_PER_NODE; assertEquals(expectedError, e.getMessage()); } Metadata clusterState = clusterAdmin().prepareState().get().getState().metadata(); diff --git a/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java b/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java index 65225530b7d38..a87f3b3d4bda0 100644 --- a/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java +++ b/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java @@ -78,6 +78,7 @@ public enum ReferenceDocs { SNAPSHOT_REPOSITORY_ANALYSIS, S3_COMPATIBLE_REPOSITORIES, LUCENE_MAX_DOCS_LIMIT, + MAX_SHARDS_PER_NODE, // this comment keeps the ';' on the next line so every entry above has a trailing ',' which makes the diff for adding new links cleaner ; diff --git a/server/src/main/resources/org/elasticsearch/common/reference-docs-links.json b/server/src/main/resources/org/elasticsearch/common/reference-docs-links.json index cd325ce9010ac..d4fb1be58d854 100644 --- a/server/src/main/resources/org/elasticsearch/common/reference-docs-links.json +++ b/server/src/main/resources/org/elasticsearch/common/reference-docs-links.json @@ -38,5 +38,6 @@ "NETWORK_BINDING_AND_PUBLISHING": "modules-network.html#modules-network-binding-publishing", "SNAPSHOT_REPOSITORY_ANALYSIS": "repo-analysis-api.html", "S3_COMPATIBLE_REPOSITORIES": "repository-s3.html#repository-s3-compatible-services", - "LUCENE_MAX_DOCS_LIMIT": "size-your-shards.html#troubleshooting-max-docs-limit" + "LUCENE_MAX_DOCS_LIMIT": "size-your-shards.html#troubleshooting-max-docs-limit", + "MAX_SHARDS_PER_NODE": "size-your-shards.html#_this_action_would_add_x_total_shards_but_this_cluster_currently_has_yz_maximum_shards_open" } From 3100fcda40869507defbdba245f8f60b0633b8b8 Mon Sep 17 00:00:00 2001 From: Stef Nestor <26751266+stefnestor@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:24:02 -0600 Subject: [PATCH 2/8] expand to the other two places this error shows --- .../cluster/shards/ClusterShardLimitIT.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java index a2415ec3d74ca..e8a8761807031 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java @@ -153,8 +153,9 @@ public void testIncreaseReplicasOverLimit() { + firstShardCount + "]/[" + dataNodes * shardsPerNode - + "] maximum normal shards open; for more information see " - + ReferenceDocs.MAX_SHARDS_PER_NODE; + + "] maximum normal shards open; for more information, see " + + ReferenceDocs.MAX_SHARDS_PER_NODE + + ";"; assertEquals(expectedError, e.getMessage()); } Metadata clusterState = clusterAdmin().prepareState().get().getState().metadata(); @@ -213,7 +214,9 @@ public void testChangingMultipleIndicesOverLimit() { + totalShardsBefore + "]/[" + dataNodes * shardsPerNode - + "] maximum normal shards open;"; + + "] maximum normal shards open; for more information, see " + + ReferenceDocs.MAX_SHARDS_PER_NODE + + ";"; assertEquals(expectedError, e.getMessage()); } Metadata clusterState = clusterAdmin().prepareState().get().getState().metadata(); @@ -405,7 +408,9 @@ private void verifyException(int dataNodes, ShardCounts counts, IllegalArgumentE + currentShards + "]/[" + maxShards - + "] maximum normal shards open;"; + + "] maximum normal shards open; for more information, see " + + ReferenceDocs.MAX_SHARDS_PER_NODE + +";"; assertEquals(expectedError, e.getMessage()); } From f854019947238b18773aba89b3ebff4ed4ccd23d Mon Sep 17 00:00:00 2001 From: Stef Nestor <26751266+stefnestor@users.noreply.github.com> Date: Wed, 17 Jul 2024 14:13:25 -0600 Subject: [PATCH 3/8] linter --- .../org/elasticsearch/cluster/shards/ClusterShardLimitIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java index e8a8761807031..31dd002a6af7d 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/shards/ClusterShardLimitIT.java @@ -410,7 +410,7 @@ private void verifyException(int dataNodes, ShardCounts counts, IllegalArgumentE + maxShards + "] maximum normal shards open; for more information, see " + ReferenceDocs.MAX_SHARDS_PER_NODE - +";"; + + ";"; assertEquals(expectedError, e.getMessage()); } From 076f71454d69697549c9cd830e54f702266548c3 Mon Sep 17 00:00:00 2001 From: Stef Nestor <26751266+stefnestor@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:28:28 -0600 Subject: [PATCH 4/8] Update docs/changelog/110993.yaml --- docs/changelog/110993.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/110993.yaml diff --git a/docs/changelog/110993.yaml b/docs/changelog/110993.yaml new file mode 100644 index 0000000000000..e7f1b0751b4e1 --- /dev/null +++ b/docs/changelog/110993.yaml @@ -0,0 +1,5 @@ +pr: 110993 +summary: (Err>Doc) Max Shards Per Node +area: Distributed +type: enhancement +issues: [] From 3d32aded5068c7df31ea7a35ad1dc95ed8dc9705 Mon Sep 17 00:00:00 2001 From: Stef Nestor <26751266+stefnestor@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:15:18 -0600 Subject: [PATCH 5/8] test --- .../java/org/elasticsearch/indices/ShardLimitValidator.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/indices/ShardLimitValidator.java b/server/src/main/java/org/elasticsearch/indices/ShardLimitValidator.java index 06bb1439be4e6..f58ee757cc511 100644 --- a/server/src/main/java/org/elasticsearch/indices/ShardLimitValidator.java +++ b/server/src/main/java/org/elasticsearch/indices/ShardLimitValidator.java @@ -13,6 +13,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeRole; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.ReferenceDocs; import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; @@ -296,7 +297,8 @@ static String errorMessageFrom(Result result) { + result.maxShardsInCluster + "] maximum " + result.group - + " shards open"; + + " shards open; for more information, see " + + ReferenceDocs.MAX_SHARDS_PER_NODE; } /** From e84a4cda688970885945d51482f5fdd1634d2e08 Mon Sep 17 00:00:00 2001 From: Stef Nestor <26751266+stefnestor@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:40:16 -0600 Subject: [PATCH 6/8] feedback --- docs/changelog/110993.yaml | 2 +- docs/reference/how-to/size-your-shards.asciidoc | 1 + .../org/elasticsearch/common/reference-docs-links.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changelog/110993.yaml b/docs/changelog/110993.yaml index e7f1b0751b4e1..9eb653a09e3a4 100644 --- a/docs/changelog/110993.yaml +++ b/docs/changelog/110993.yaml @@ -1,5 +1,5 @@ pr: 110993 -summary: (Err>Doc) Max Shards Per Node +summary: Add link to Max Shards Per Node exception message area: Distributed type: enhancement issues: [] diff --git a/docs/reference/how-to/size-your-shards.asciidoc b/docs/reference/how-to/size-your-shards.asciidoc index 31f4039bcfaca..ba0c0ab8b0b15 100644 --- a/docs/reference/how-to/size-your-shards.asciidoc +++ b/docs/reference/how-to/size-your-shards.asciidoc @@ -501,6 +501,7 @@ POST _reindex Here’s how to resolve common shard-related errors. [discrete] +[[troubleshooting-max-shards-open]] ==== this action would add [x] total shards, but this cluster currently has [y]/[z] maximum shards open; The <> cluster diff --git a/server/src/main/resources/org/elasticsearch/common/reference-docs-links.json b/server/src/main/resources/org/elasticsearch/common/reference-docs-links.json index d4fb1be58d854..0d11629803ced 100644 --- a/server/src/main/resources/org/elasticsearch/common/reference-docs-links.json +++ b/server/src/main/resources/org/elasticsearch/common/reference-docs-links.json @@ -39,5 +39,5 @@ "SNAPSHOT_REPOSITORY_ANALYSIS": "repo-analysis-api.html", "S3_COMPATIBLE_REPOSITORIES": "repository-s3.html#repository-s3-compatible-services", "LUCENE_MAX_DOCS_LIMIT": "size-your-shards.html#troubleshooting-max-docs-limit", - "MAX_SHARDS_PER_NODE": "size-your-shards.html#_this_action_would_add_x_total_shards_but_this_cluster_currently_has_yz_maximum_shards_open" + "MAX_SHARDS_PER_NODE": "size-your-shards.html#troubleshooting-max-shards-open" } From 7ba80c3731ce8df4986af49912336f7fbccfefd1 Mon Sep 17 00:00:00 2001 From: Stef Nestor <26751266+stefnestor@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:12:55 -0600 Subject: [PATCH 7/8] +ShardLimitValidatorTests --- .../indices/ShardLimitValidatorTests.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java b/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java index e1b3bb4fe9c49..c55636a1a6881 100644 --- a/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java +++ b/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java @@ -16,6 +16,7 @@ import org.elasticsearch.cluster.node.DiscoveryNodeUtils; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.ReferenceDocs; import org.elasticsearch.cluster.shards.ShardCounts; import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.settings.ClusterSettings; @@ -79,7 +80,8 @@ private void testOverShardLimit(CheckShardLimitMethod targetMethod, String group + maxShards + "] maximum " + group - + " shards open", + + " shards open; for more information, see " + + ReferenceDocs.MAX_SHARDS_PER_NODE, ShardLimitValidator.errorMessageFrom(shardLimitsResult) ); assertEquals(shardLimitsResult.maxShardsInCluster(), maxShards); @@ -151,7 +153,9 @@ public void testValidateShardLimitOpenIndices() { + maxShards + "] maximum " + group - + " shards open;", + + " shards open; for more information, see " + + ReferenceDocs.MAX_SHARDS_PER_NODE + + ";", exception.getMessage() ); } @@ -179,7 +183,9 @@ public void testValidateShardLimitUpdateReplicas() { + shardsPerNode * nodesInCluster + "] maximum " + group - + " shards open;", + + " shards open; for more information, see " + + ReferenceDocs.MAX_SHARDS_PER_NODE + + ";", exception.getMessage() ); } From 60cb5f7e9bd13b61c96e61195b41d622ac77982e Mon Sep 17 00:00:00 2001 From: Stef Nestor <26751266+stefnestor@users.noreply.github.com> Date: Sat, 20 Jul 2024 14:08:40 -0600 Subject: [PATCH 8/8] linter --- .../org/elasticsearch/indices/ShardLimitValidatorTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java b/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java index c55636a1a6881..0eea536ddbff1 100644 --- a/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java +++ b/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java @@ -16,8 +16,8 @@ import org.elasticsearch.cluster.node.DiscoveryNodeUtils; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.ReferenceDocs; import org.elasticsearch.cluster.shards.ShardCounts; +import org.elasticsearch.common.ReferenceDocs; import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Setting;