Skip to content

feat: retry transient item failures in bulk ingestion - #4243

Open
falscherwiener1-svg wants to merge 3 commits into
elastic:mainfrom
falscherwiener1-svg:feat/4002-retry-bulk-item-errors
Open

feat: retry transient item failures in bulk ingestion#4243
falscherwiener1-svg wants to merge 3 commits into
elastic:mainfrom
falscherwiener1-svg:feat/4002-retry-bulk-item-errors

Conversation

@falscherwiener1-svg

Copy link
Copy Markdown

Description

Add per-item retry logic for transient HTTP status codes (429, 503)
in the bulk ingestion sink. Previously, individual items that failed
with transient errors inside a successful bulk response were sent
directly to the ErrorMonitor without retry, which could trigger a
premature TooManyErrors abort on a temporarily overloaded cluster.

Changes

  • Add TRANSIENT_STATUS_CODES constant (429, 503)
  • Add _determine_action() helper to extract the bulk action key from a response item
  • Add _extract_transient_failed_operations() to collect retryable items from a bulk response
  • Add _retry_transient_item_failures() with exponential backoff that retries only the failed items
  • Rewire _batch_bulk to call _retry_transient_item_failures before _process_bulk_response, so the ErrorMonitor only tracks failures after all retry attempts are exhausted
  • Remove the now-unused retryable import and the dead _bulk_api_call function that was never invoked

Testing

  • test_extract_transient_failed_operations_returns_empty_when_all_successful
  • test_extract_transient_failed_operations_returns_429_items
  • test_retry_transient_item_failures_retries_429_items
  • test_retry_transient_item_failures_gives_up_after_exhaustion
  • test_batch_bulk_with_transient_item_retries_integration

Closes

Closes #4002

Add per-item retry logic for transient HTTP status codes (429, 503)
in the bulk ingestion sink. Previously, individual items that failed
with transient errors inside a successful bulk response were sent
directly to the ErrorMonitor without retry, which could trigger a
premature TooManyErrors abort on a temporarily overloaded cluster.

Changes:
- Add TRANSIENT_STATUS_CODES constant (429, 503)
- Add _determine_action() helper to extract the bulk action key from a
  response item
- Add _extract_transient_failed_operations() to collect retryable
  items from a bulk response
- Add _retry_transient_item_failures() with exponential backoff that
  retries only the failed items
- Rewire _batch_bulk to call _retry_transient_item_failures before
  _process_bulk_response, so the ErrorMonitor only tracks failures
  after all retry attempts are exhausted
- Remove the now-unused retryable import and the dead _bulk_api_call
  function that was never invoked

Closes elastic#4002
@falscherwiener1-svg
falscherwiener1-svg requested a review from a team as a code owner July 20, 2026 21:14
@cla-checker-service

cla-checker-service Bot commented Jul 20, 2026

Copy link
Copy Markdown

💚 CLA has been signed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle item-level failures when doing bulk ingestion

1 participant