From 34aa456cecfb3b058266f2e83d8119e6f2680691 Mon Sep 17 00:00:00 2001 From: Stef Nestor <26751266+stefnestor@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:14:37 -0600 Subject: [PATCH 1/3] Add link to CircuitBreaker exception message --- .../java/org/elasticsearch/common/ReferenceDocs.java | 1 + .../common/breaker/ChildMemoryCircuitBreaker.java | 4 +++- .../indices/breaker/HierarchyCircuitBreakerService.java | 5 +++-- .../breaker/HierarchyCircuitBreakerServiceTests.java | 9 +++++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java b/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java index 37f4a5ce52295..8ee326fcbd822 100644 --- a/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java +++ b/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java @@ -84,6 +84,7 @@ public enum ReferenceDocs { FLOOD_STAGE_WATERMARK, X_OPAQUE_ID, FORMING_SINGLE_NODE_CLUSTERS, + CIRCUIT_BREAKER, // 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/java/org/elasticsearch/common/breaker/ChildMemoryCircuitBreaker.java b/server/src/main/java/org/elasticsearch/common/breaker/ChildMemoryCircuitBreaker.java index 6d8510d27f27a..4f379f48bd5f1 100644 --- a/server/src/main/java/org/elasticsearch/common/breaker/ChildMemoryCircuitBreaker.java +++ b/server/src/main/java/org/elasticsearch/common/breaker/ChildMemoryCircuitBreaker.java @@ -10,6 +10,7 @@ package org.elasticsearch.common.breaker; import org.apache.logging.log4j.Logger; +import org.elasticsearch.common.ReferenceDocs; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.indices.breaker.BreakerSettings; import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService; @@ -87,7 +88,8 @@ public void circuitBreak(String fieldName, long bytesNeeded) { + memoryBytesLimit + "/" + ByteSizeValue.ofBytes(memoryBytesLimit) - + "]"; + + "]; for more information, see " + + ReferenceDocs.CIRCUIT_BREAKER; logger.debug(() -> format("%s", message)); throw new CircuitBreakingException(message, bytesNeeded, memoryBytesLimit, durability); } diff --git a/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java b/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java index d72909806240c..c5c4c9a832ad0 100644 --- a/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java +++ b/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java @@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.elasticsearch.common.ReferenceDocs; import org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker; import org.elasticsearch.common.breaker.CircuitBreaker; import org.elasticsearch.common.breaker.CircuitBreakingException; @@ -450,7 +451,6 @@ static String buildParentTripMessage( appendBytesSafe(message, memoryUsed.totalUsage); message.append("], which is larger than the limit of ["); appendBytesSafe(message, parentLimit); - message.append("]"); if (trackRealMemoryUsage) { final long realUsage = memoryUsed.baseUsage; message.append(", real usage: ["); @@ -474,7 +474,8 @@ public void accept(String key, CircuitBreaker breaker) { appendBytesSafe(message, (long) (breaker.getUsed() * breaker.getOverhead())); } }); - message.append("]"); + message.append("]; for more information, see "); + message.append(ReferenceDocs.CIRCUIT_BREAKER); return message.toString(); } diff --git a/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerServiceTests.java b/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerServiceTests.java index 156460d320ee2..29643abce2ae0 100644 --- a/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerServiceTests.java +++ b/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerServiceTests.java @@ -22,6 +22,7 @@ import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.search.aggregations.MultiBucketConsumerService; import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.common.ReferenceDocs; import java.util.ArrayList; import java.util.Arrays; @@ -911,9 +912,9 @@ public double getOverhead() { ), oneOf( "[parent] Data too large, data for [test] would be [3/3b], which is larger than the limit of [6/6b], " - + "usages [child=7/7b, otherChild=8/8b]", + + "usages [child=7/7b, otherChild=8/8b]; for more information, see "+ ReferenceDocs.CIRCUIT_BREAKER, "[parent] Data too large, data for [test] would be [3/3b], which is larger than the limit of [6/6b], " - + "usages [otherChild=8/8b, child=7/7b]" + + "usages [otherChild=8/8b, child=7/7b]; for more information, see "+ ReferenceDocs.CIRCUIT_BREAKER ) ); @@ -928,7 +929,7 @@ public double getOverhead() { ), equalTo( "[parent] Data too large, data for [test] would be [3/3b], which is larger than the limit of [6/6b], " - + "real usage: [2/2b], new bytes reserved: [1/1b], usages []" + + "real usage: [2/2b], new bytes reserved: [1/1b], usages []; for more information, see "+ ReferenceDocs.CIRCUIT_BREAKER ) ); @@ -945,7 +946,7 @@ public double getOverhead() { ), equalTo( "[parent] Data too large, data for [test] would be [-3], which is larger than the limit of [-6], " - + "real usage: [-2], new bytes reserved: [-1/-1b], usages [child1=-7]" + + "real usage: [-2], new bytes reserved: [-1/-1b], usages [child1=-7]; for more information, see "+ ReferenceDocs.CIRCUIT_BREAKER" ) ); } finally { From ee91e979ac2d500f59d3d34845e0fdaa144e27d1 Mon Sep 17 00:00:00 2001 From: Stef Nestor <26751266+stefnestor@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:21:47 -0600 Subject: [PATCH 2/3] fix --- .../org/elasticsearch/common/ReferenceDocs.java | 2 +- .../common/breaker/ChildMemoryCircuitBreaker.java | 2 +- .../breaker/HierarchyCircuitBreakerService.java | 3 ++- .../elasticsearch/common/reference-docs-links.json | 3 ++- .../HierarchyCircuitBreakerServiceTests.java | 14 +++++++++----- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java b/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java index 8ee326fcbd822..65b2f127a74a8 100644 --- a/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java +++ b/server/src/main/java/org/elasticsearch/common/ReferenceDocs.java @@ -84,7 +84,7 @@ public enum ReferenceDocs { FLOOD_STAGE_WATERMARK, X_OPAQUE_ID, FORMING_SINGLE_NODE_CLUSTERS, - CIRCUIT_BREAKER, + CIRCUIT_BREAKER_ERRORS, // 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/java/org/elasticsearch/common/breaker/ChildMemoryCircuitBreaker.java b/server/src/main/java/org/elasticsearch/common/breaker/ChildMemoryCircuitBreaker.java index 4f379f48bd5f1..9669e78a119b9 100644 --- a/server/src/main/java/org/elasticsearch/common/breaker/ChildMemoryCircuitBreaker.java +++ b/server/src/main/java/org/elasticsearch/common/breaker/ChildMemoryCircuitBreaker.java @@ -89,7 +89,7 @@ public void circuitBreak(String fieldName, long bytesNeeded) { + "/" + ByteSizeValue.ofBytes(memoryBytesLimit) + "]; for more information, see " - + ReferenceDocs.CIRCUIT_BREAKER; + + ReferenceDocs.CIRCUIT_BREAKER_ERRORS; logger.debug(() -> format("%s", message)); throw new CircuitBreakingException(message, bytesNeeded, memoryBytesLimit, durability); } diff --git a/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java b/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java index c5c4c9a832ad0..b1b0f0201ebbe 100644 --- a/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java +++ b/server/src/main/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerService.java @@ -451,6 +451,7 @@ static String buildParentTripMessage( appendBytesSafe(message, memoryUsed.totalUsage); message.append("], which is larger than the limit of ["); appendBytesSafe(message, parentLimit); + message.append("]"); if (trackRealMemoryUsage) { final long realUsage = memoryUsed.baseUsage; message.append(", real usage: ["); @@ -475,7 +476,7 @@ public void accept(String key, CircuitBreaker breaker) { } }); message.append("]; for more information, see "); - message.append(ReferenceDocs.CIRCUIT_BREAKER); + message.append(ReferenceDocs.CIRCUIT_BREAKER_ERRORS); return message.toString(); } 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 4da6de7f7b561..616ae7dfc16f0 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 @@ -43,5 +43,6 @@ "MAX_SHARDS_PER_NODE": "size-your-shards.html#troubleshooting-max-shards-open", "FLOOD_STAGE_WATERMARK": "fix-watermark-errors.html", "X_OPAQUE_ID": "api-conventions.html#x-opaque-id", - "FORMING_SINGLE_NODE_CLUSTERS": "modules-discovery-bootstrap-cluster.html#modules-discovery-bootstrap-cluster-joining" + "FORMING_SINGLE_NODE_CLUSTERS": "modules-discovery-bootstrap-cluster.html#modules-discovery-bootstrap-cluster-joining", + "CIRCUIT_BREAKER_ERRORS": "circuit-breaker-errors.html" } diff --git a/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerServiceTests.java b/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerServiceTests.java index 29643abce2ae0..610e87b50d365 100644 --- a/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerServiceTests.java +++ b/server/src/test/java/org/elasticsearch/indices/breaker/HierarchyCircuitBreakerServiceTests.java @@ -9,6 +9,7 @@ package org.elasticsearch.indices.breaker; +import org.elasticsearch.common.ReferenceDocs; import org.elasticsearch.common.breaker.ChildMemoryCircuitBreaker; import org.elasticsearch.common.breaker.CircuitBreaker; import org.elasticsearch.common.breaker.CircuitBreakingException; @@ -22,7 +23,6 @@ import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.search.aggregations.MultiBucketConsumerService; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.common.ReferenceDocs; import java.util.ArrayList; import java.util.Arrays; @@ -912,9 +912,11 @@ public double getOverhead() { ), oneOf( "[parent] Data too large, data for [test] would be [3/3b], which is larger than the limit of [6/6b], " - + "usages [child=7/7b, otherChild=8/8b]; for more information, see "+ ReferenceDocs.CIRCUIT_BREAKER, + + "usages [child=7/7b, otherChild=8/8b]; for more information, see " + + ReferenceDocs.CIRCUIT_BREAKER_ERRORS, "[parent] Data too large, data for [test] would be [3/3b], which is larger than the limit of [6/6b], " - + "usages [otherChild=8/8b, child=7/7b]; for more information, see "+ ReferenceDocs.CIRCUIT_BREAKER + + "usages [otherChild=8/8b, child=7/7b]; for more information, see " + + ReferenceDocs.CIRCUIT_BREAKER_ERRORS ) ); @@ -929,7 +931,8 @@ public double getOverhead() { ), equalTo( "[parent] Data too large, data for [test] would be [3/3b], which is larger than the limit of [6/6b], " - + "real usage: [2/2b], new bytes reserved: [1/1b], usages []; for more information, see "+ ReferenceDocs.CIRCUIT_BREAKER + + "real usage: [2/2b], new bytes reserved: [1/1b], usages []; for more information, see " + + ReferenceDocs.CIRCUIT_BREAKER_ERRORS ) ); @@ -946,7 +949,8 @@ public double getOverhead() { ), equalTo( "[parent] Data too large, data for [test] would be [-3], which is larger than the limit of [-6], " - + "real usage: [-2], new bytes reserved: [-1/-1b], usages [child1=-7]; for more information, see "+ ReferenceDocs.CIRCUIT_BREAKER" + + "real usage: [-2], new bytes reserved: [-1/-1b], usages [child1=-7]; for more information, see " + + ReferenceDocs.CIRCUIT_BREAKER_ERRORS ) ); } finally { From b5debc9df4bac7718a39c3e0f7f95c3a422e2562 Mon Sep 17 00:00:00 2001 From: Stef Nestor <26751266+stefnestor@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:27:38 -0600 Subject: [PATCH 3/3] Update docs/changelog/113561.yaml --- docs/changelog/113561.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/changelog/113561.yaml diff --git a/docs/changelog/113561.yaml b/docs/changelog/113561.yaml new file mode 100644 index 0000000000000..d00eac7685bcc --- /dev/null +++ b/docs/changelog/113561.yaml @@ -0,0 +1,5 @@ +pr: 113561 +summary: Add link to Circuit Breaker "Data too large" exception message +area: Infra/Circuit Breakers +type: enhancement +issues: []