Skip to content

Commit 92c6c98

Browse files
authored
Performance fix. Reduce deprecation calls for the same bulk request (#37415)
DeprecationLogger has warning de-duplication logic but it is expensive to run as it involves parsing existing warning headers. This PR changes the upstream bulk indexing code to do its own "event thinning" rather than relying on DeprecationLogger's trimming. Closes #37411
1 parent 2ee55a5 commit 92c6c98

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null
366366
int from = 0;
367367
int length = data.length();
368368
byte marker = xContent.streamSeparator();
369+
boolean typesDeprecationLogged = false;
369370
while (true) {
370371
int nextMarker = findNextMarker(marker, from, data, length);
371372
if (nextMarker == -1) {
@@ -427,7 +428,10 @@ public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Null
427428
}
428429
index = parser.text();
429430
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
430-
deprecationLogger.deprecatedAndMaybeLog("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE);
431+
if (typesDeprecationLogged == false) {
432+
deprecationLogger.deprecatedAndMaybeLog("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE);
433+
typesDeprecationLogged = true;
434+
}
431435
type = parser.text();
432436
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
433437
id = parser.text();

0 commit comments

Comments
 (0)