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
This commit is contained in:
markharwood 2019-01-14 17:51:49 +00:00 committed by GitHub
parent 2ee55a50bf
commit 92c6c98e8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -366,6 +366,7 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
int from = 0;
int length = data.length();
byte marker = xContent.streamSeparator();
boolean typesDeprecationLogged = false;
while (true) {
int nextMarker = findNextMarker(marker, from, data, length);
if (nextMarker == -1) {
@ -427,7 +428,10 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
}
index = parser.text();
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
deprecationLogger.deprecatedAndMaybeLog("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE);
if (typesDeprecationLogged == false) {
deprecationLogger.deprecatedAndMaybeLog("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE);
typesDeprecationLogged = true;
}
type = parser.text();
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
id = parser.text();