Skip to content

Commit b1a6271

Browse files
authored
Add configured indexing memory limit to node stats (#60342)
This commit adds the configured memory limit to the node stats API.
1 parent 821102d commit b1a6271

File tree

5 files changed

+49
-4
lines changed

5 files changed

+49
-4
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ tasks.register("verifyVersions") {
174174
* after the backport of the backcompat code is complete.
175175
*/
176176

177-
boolean bwc_tests_enabled = true
178-
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
177+
boolean bwc_tests_enabled = false
178+
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/60342" /* place a PR link here when committing bwc changes */
179179
if (bwc_tests_enabled == false) {
180180
if (bwc_tests_disabled_issue.isEmpty()) {
181181
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")

docs/reference/cluster/nodes-stats.asciidoc

+9
Original file line numberDiff line numberDiff line change
@@ -2227,6 +2227,15 @@ Number of indexing requests rejected in the primary stage.
22272227
(integer)
22282228
Number of indexing requests rejected in the replica stage.
22292229
========
2230+
`limit`::
2231+
(<<byte-units,byte value>>)
2232+
Configured memory limit for the indexing requests. Replica requests have an
2233+
automatic limit that is 1.5x this value.
2234+
2235+
`limit_in_bytes`::
2236+
(integer)
2237+
Configured memory limit, in bytes, for the indexing requests. Replica requests
2238+
have an automatic limit that is 1.5x this value.
22302239
=======
22312240
======
22322241

rest-api-spec/src/main/resources/rest-api-spec/test/nodes.stats/50_indexing_pressure.yml

+18
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,21 @@
2929
- gte: { nodes.$node_id.indexing_pressure.memory.total.coordinating_rejections: 0 }
3030
- gte: { nodes.$node_id.indexing_pressure.memory.total.primary_rejections: 0 }
3131
- gte: { nodes.$node_id.indexing_pressure.memory.total.replica_rejections: 0 }
32+
---
33+
"Indexing pressure memory limit":
34+
- skip:
35+
# Change to 7.9.99 on backport
36+
version: " - 7.10.99"
37+
reason: "memory limit was added in 7.10"
38+
features: [arbitrary_key]
39+
40+
- do:
41+
nodes.info: {}
42+
- set:
43+
nodes._arbitrary_key_: node_id
44+
45+
- do:
46+
nodes.stats:
47+
metric: [ indexing_pressure ]
48+
49+
- gte: { nodes.$node_id.indexing_pressure.memory.limit_in_bytes: 0 }

server/src/main/java/org/elasticsearch/index/IndexingPressure.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,6 @@ public IndexingPressureStats stats() {
146146
return new IndexingPressureStats(totalCombinedCoordinatingAndPrimaryBytes.get(), totalCoordinatingBytes.get(),
147147
totalPrimaryBytes.get(), totalReplicaBytes.get(), currentCombinedCoordinatingAndPrimaryBytes.get(),
148148
currentCoordinatingBytes.get(), currentPrimaryBytes.get(), currentReplicaBytes.get(), coordinatingRejections.get(),
149-
primaryRejections.get(), replicaRejections.get());
149+
primaryRejections.get(), replicaRejections.get(), primaryAndCoordinatingLimits);
150150
}
151151
}

server/src/main/java/org/elasticsearch/index/stats/IndexingPressureStats.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.elasticsearch.index.stats;
2121

22+
import org.elasticsearch.Version;
2223
import org.elasticsearch.common.io.stream.StreamInput;
2324
import org.elasticsearch.common.io.stream.StreamOutput;
2425
import org.elasticsearch.common.io.stream.Writeable;
@@ -43,6 +44,7 @@ public class IndexingPressureStats implements Writeable, ToXContentFragment {
4344
private final long coordinatingRejections;
4445
private final long primaryRejections;
4546
private final long replicaRejections;
47+
private final long memoryLimit;
4648

4749
public IndexingPressureStats(StreamInput in) throws IOException {
4850
totalCombinedCoordinatingAndPrimaryBytes = in.readVLong();
@@ -58,12 +60,19 @@ public IndexingPressureStats(StreamInput in) throws IOException {
5860
coordinatingRejections = in.readVLong();
5961
primaryRejections = in.readVLong();
6062
replicaRejections = in.readVLong();
63+
64+
// TODO: Change to 7.10 after backport
65+
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
66+
memoryLimit = in.readVLong();
67+
} else {
68+
memoryLimit = -1L;
69+
}
6170
}
6271

6372
public IndexingPressureStats(long totalCombinedCoordinatingAndPrimaryBytes, long totalCoordinatingBytes, long totalPrimaryBytes,
6473
long totalReplicaBytes, long currentCombinedCoordinatingAndPrimaryBytes, long currentCoordinatingBytes,
6574
long currentPrimaryBytes, long currentReplicaBytes, long coordinatingRejections, long primaryRejections,
66-
long replicaRejections) {
75+
long replicaRejections, long memoryLimit) {
6776
this.totalCombinedCoordinatingAndPrimaryBytes = totalCombinedCoordinatingAndPrimaryBytes;
6877
this.totalCoordinatingBytes = totalCoordinatingBytes;
6978
this.totalPrimaryBytes = totalPrimaryBytes;
@@ -75,6 +84,7 @@ public IndexingPressureStats(long totalCombinedCoordinatingAndPrimaryBytes, long
7584
this.coordinatingRejections = coordinatingRejections;
7685
this.primaryRejections = primaryRejections;
7786
this.replicaRejections = replicaRejections;
87+
this.memoryLimit = memoryLimit;
7888
}
7989

8090
@Override
@@ -92,6 +102,11 @@ public void writeTo(StreamOutput out) throws IOException {
92102
out.writeVLong(coordinatingRejections);
93103
out.writeVLong(primaryRejections);
94104
out.writeVLong(replicaRejections);
105+
106+
// TODO: Change to 7.10 after backport
107+
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
108+
out.writeVLong(memoryLimit);
109+
}
95110
}
96111

97112
public long getTotalCombinedCoordinatingAndPrimaryBytes() {
@@ -151,6 +166,8 @@ public long getReplicaRejections() {
151166
private static final String COORDINATING_REJECTIONS = "coordinating_rejections";
152167
private static final String PRIMARY_REJECTIONS = "primary_rejections";
153168
private static final String REPLICA_REJECTIONS = "replica_rejections";
169+
private static final String LIMIT = "limit";
170+
private static final String LIMIT_IN_BYTES = "limit_in_bytes";
154171

155172
@Override
156173
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
@@ -173,6 +190,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
173190
builder.field(PRIMARY_REJECTIONS, primaryRejections);
174191
builder.field(REPLICA_REJECTIONS, replicaRejections);
175192
builder.endObject();
193+
builder.humanReadableField(LIMIT_IN_BYTES, LIMIT, new ByteSizeValue(memoryLimit));
176194
builder.endObject();
177195
return builder.endObject();
178196
}

0 commit comments

Comments
 (0)