Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,20 @@ private BulkOperationRequestResponse handleRetriesAndFailures(final Accumulating
if (attemptNumber % 5 == 1) {
LOG.warn("Bulk Operation Failed. Number of retries {}. Retrying... ", attemptNumber - 1, exceptionFromRequest);
if (exceptionFromRequest == null) {
int throttledCount = 0;
for (final BulkResponseItem bulkItemResponse : bulkResponse.items()) {
if(isItemInError(bulkItemResponse)) {
final ErrorCause error = bulkItemResponse.error();
LOG.warn("index = {} operation = {}, error = {}", bulkItemResponse.index(), bulkItemResponse.operationType(), error != null ? error.reason() : "");
if (bulkItemResponse.status() == RestStatus.TOO_MANY_REQUESTS.getStatus()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The checklist says tests were added, but BulkRetryStrategyTests is unchanged. Could you add a test with several 429 items and one other error, checking that the 429s give one summary line and the other error is still logged on its own?

throttledCount++;
} else {
final ErrorCause error = bulkItemResponse.error();
LOG.warn("index = {} operation = {}, error = {}", bulkItemResponse.index(), bulkItemResponse.operationType(), error != null ? error.reason() : "");
}
}
}
if (throttledCount > 0) {
LOG.warn("Bulk operation throttled for {} documents", throttledCount);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should match the log line above where this used to go.

It should include the index, operation, and the error reason. On the reason, might OpenSearch give some additional details for the throttling that can be useful?

}
}
}
bulkRequestNumberOfRetries.increment();
Expand All @@ -325,16 +333,24 @@ private BulkOperationRequestResponse handleRetriesAndFailures(final Accumulating

private void handleFailures(final AccumulatingBulkRequest<BulkOperationWrapper, BulkRequest> bulkRequest, final BulkResponse bulkResponse, final Throwable failure) {
if (failure == null) {
int throttledCount = 0;
for (final BulkResponseItem bulkItemResponse : bulkResponse.items()) {
if(isItemInError(bulkItemResponse)) {
// Skip logging the error for version conflicts when using external versioning
final ErrorCause error = bulkItemResponse.error();
if (isExternalVersioning && error != null && VERSION_CONFLICT_EXCEPTION_TYPE.equals(error.type())) {
continue;
}
LOG.warn("index = {}, operation = {}, status = {}, error = {}", bulkItemResponse.index(), bulkItemResponse.operationType(), bulkItemResponse.status(), error != null ? error.reason() : "");
if (bulkItemResponse.status() == RestStatus.TOO_MANY_REQUESTS.getStatus()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@graytaylor0, I think this branch can never run. handleFailures with a response is only called when canRetry(bulkResponse) is false, and any 429 item makes canRetry true, because 429 is not in NON_RETRY_STATUS. When retries run out, execute calls handleFailures with a failure instead, which skips this loop. I checked with a probe over 4,660 runs of mixed item statuses: this method ran 648 times and never saw a 429. Could you remove this hunk and keep only the change in the retry log?

throttledCount++;
} else {
LOG.warn("index = {}, operation = {}, status = {}, error = {}", bulkItemResponse.index(), bulkItemResponse.operationType(), bulkItemResponse.status(), error != null ? error.reason() : "");
}
}
}
if (throttledCount > 0) {
LOG.warn("Bulk operation throttled for {} documents", throttledCount);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

}
handleFailures(bulkRequest, bulkResponse.items());
} else {
LOG.warn("Bulk Operation Failed.", failure);
Expand Down
Loading