Skip to content

Commit f8b8814

Browse files
committed
Review comments
1 parent 2c3d38b commit f8b8814

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

server/src/main/java/org/elasticsearch/action/support/replication/TransportWriteAction.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,12 @@ protected Releasable checkPrimaryLimits(Request request, boolean rerouteWasLocal
143143
// If this primary request was received from a local reroute initiated by the node client, we
144144
// must mark a new primary operation local to the coordinating node.
145145
if (localRerouteInitiatedByNodeClient) {
146-
indexingPressure.checkLargestPrimaryOperationIsWithinLimits(
146+
return indexingPressure.validateAndMarkPrimaryOperationLocalToCoordinatingNodeStarted(
147147
primaryOperationCount(request),
148+
primaryOperationSize(request),
148149
primaryLargestOperationSize(request),
149150
primaryAllowsOperationsBeyondSizeLimit(request)
150151
);
151-
return indexingPressure.markPrimaryOperationLocalToCoordinatingNodeStarted(
152-
primaryOperationCount(request),
153-
primaryOperationSize(request)
154-
);
155152
} else {
156153
return () -> {};
157154
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,13 @@ public Releasable markCoordinatingOperationStarted(int operations, long bytes, b
193193
});
194194
}
195195

196-
public Releasable markPrimaryOperationLocalToCoordinatingNodeStarted(int operations, long bytes) {
196+
public Releasable validateAndMarkPrimaryOperationLocalToCoordinatingNodeStarted(
197+
int operations,
198+
long bytes,
199+
long largestOperationSizeInBytes,
200+
boolean allowsOperationsBeyondSizeLimit
201+
) {
202+
checkLargestPrimaryOperationIsWithinLimits(operations, largestOperationSizeInBytes, allowsOperationsBeyondSizeLimit);
197203
currentPrimaryBytes.getAndAdd(bytes);
198204
currentPrimaryOps.getAndAdd(operations);
199205
totalPrimaryBytes.getAndAdd(bytes);
@@ -204,7 +210,7 @@ public Releasable markPrimaryOperationLocalToCoordinatingNodeStarted(int operati
204210
});
205211
}
206212

207-
public void checkLargestPrimaryOperationIsWithinLimits(
213+
void checkLargestPrimaryOperationIsWithinLimits(
208214
int operations,
209215
long largestOperationSizeInBytes,
210216
boolean allowsOperationsBeyondSizeLimit

server/src/test/java/org/elasticsearch/index/IndexingPressureTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void testAvoidDoubleMemoryAccounting() {
124124
IndexingPressure indexingPressure = new IndexingPressure(settings);
125125
try (
126126
Releasable coordinating = indexingPressure.markCoordinatingOperationStarted(1, 10, false);
127-
Releasable primary = indexingPressure.markPrimaryOperationLocalToCoordinatingNodeStarted(1, 15)
127+
Releasable primary = indexingPressure.validateAndMarkPrimaryOperationLocalToCoordinatingNodeStarted(1, 15, 15, true)
128128
) {
129129
IndexingPressureStats stats = indexingPressure.stats();
130130
assertEquals(10, stats.getCurrentCoordinatingBytes());
@@ -170,7 +170,7 @@ public void testCoordinatingPrimaryRejections() {
170170

171171
// Local to coordinating node primary actions not rejected
172172
IndexingPressureStats preLocalStats = indexingPressure.stats();
173-
Releasable local = indexingPressure.markPrimaryOperationLocalToCoordinatingNodeStarted(1, 1024 * 2);
173+
Releasable local = indexingPressure.validateAndMarkPrimaryOperationLocalToCoordinatingNodeStarted(1, 1024 * 2, 1024 * 2, true);
174174
assertEquals(preLocalStats.getPrimaryRejections(), indexingPressure.stats().getPrimaryRejections());
175175
assertEquals(1024 * 6, indexingPressure.stats().getCurrentCombinedCoordinatingAndPrimaryBytes());
176176
assertEquals(preLocalStats.getCurrentPrimaryBytes() + 1024 * 2, indexingPressure.stats().getCurrentPrimaryBytes());

0 commit comments

Comments
 (0)