Skip to content

Aggregate bulk operation logs for 429 errors - #7227

Open
graytaylor0 wants to merge 1 commit into
opensearch-project:mainfrom
graytaylor0:LogAggregate429
Open

graytaylor0 wants to merge 1 commit into
opensearch-project:mainfrom
graytaylor0:LogAggregate429

Conversation

@graytaylor0

@graytaylor0 graytaylor0 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Description

When throttled in the opensearch sink, the pipeline iterates over every bulk operation and logs the same throttled error over and over which is unnecessary. This change aggregates the throttling errors per bulk request into a single log.

Issues Resolved

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

static final long INITIAL_DELAY_MS = 50;
static final long MAXIMUM_DELAY_MS = Duration.ofMinutes(10).toMillis();
static final String VERSION_CONFLICT_EXCEPTION_TYPE = "version_conflict_engine_exception";
private static final int TOO_MANY_REQUESTS_STATUS = RestStatus.TOO_MANY_REQUESTS.getStatus();

This comment was marked as outdated.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 88e4d01)

Here are some key observations to aid the review process:

🧪 No relevant tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ No major issues detected

Signed-off-by: Taylor Gray <tylgry@amazon.com>
@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 88e4d01

}
}
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?

}
}
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.

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?

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants