Skip to content

[AGENT-16861] Fix silent log loss on transient network errors - #92

Merged
ddrthall merged 1 commit into
masterfrom
ryanhall/AGENT-16861-reraise-transient-write-errors
Aug 28, 2026
Merged

ddrthall merged 1 commit into
masterfrom
ryanhall/AGENT-16861-reraise-transient-write-errors

Conversation

@ddrthall

Copy link
Copy Markdown
Collaborator

Summary

fluent-plugin-datadog silently dropped in-flight log batches on transient network interruptions. Two gaps combined:

  1. On the HTTP transport, raw network exceptions (Net::ReadTimeout, EOFError, Errno::ECONNRESET, etc.) raised by the persistent client were not classified as RetryableError, so the plugin's own send_retries never retried them. (Ruby's Net::HTTP won't retry a POST for us — POST is non-idempotent.)
  2. write(chunk) wrapped its body in rescue Exception => e and only logged, returning normally. Because a normal return signals success, Fluentd core committed and purged the chunk — its buffer retry never engaged.

Net effect: on a transient blip, a batch of records was dropped with no retry from either the plugin or Fluentd core, and no operator-visible failure.

Changes

  • Classify transient network errors as retryable in DatadogHTTPClient#send (mirrors the exception set Net::HTTP retries for idempotent requests, plus Net::HTTP::Persistent::Error), routing them through the existing send_retries backoff loop.
  • Re-raise from send_retries once bounded retries are exhausted, instead of returning normally and silently dropping the payload.
  • Log then re-raise in write (narrowed from Exception to StandardError, so SystemExit/Interrupt are not trapped) so Fluentd core's buffer retry/backoff engages as designed.

The two retry layers are complementary: plugin-level send_retries retries only the failing batch (avoiding duplicate re-sends of already-accepted batches within a multi-batch chunk), while Fluentd core provides durability, backpressure, and bounded retry lifetime as the backstop.

Test plan

  • bundle exec rake test — 44 tests, 0 failures
  • HTTP send raises RetryableError on Net::ReadTimeout, EOFError, Errno::ECONNRESET
  • send_retries re-raises after bounded exhaustion; does not retry non-retryable errors
  • write propagates rather than swallows a client failure

Fixes AGENT-16861.

Transient HTTP network failures (Net::ReadTimeout, EOFError,
Errno::ECONNRESET, etc.) were not classified as retryable and were then
swallowed by write's blanket rescue, so neither the plugin's own retry
nor Fluentd core's buffer retry engaged and the in-flight batch was
silently dropped.

- Classify transient network exceptions raised by the HTTP client as
  RetryableError so send_retries handles them.
- Re-raise from send_retries once bounded retries are exhausted instead
  of returning normally.
- Log then re-raise in write (narrowed to StandardError) so Fluentd
  core's buffer retry/backoff engages.

Adds unit tests covering all three paths.

AGENT-16861
@ddrthall
ddrthall force-pushed the ryanhall/AGENT-16861-reraise-transient-write-errors branch from fcbe7c4 to 52c9997 Compare August 27, 2026 14:40
@ddrthall
ddrthall marked this pull request as ready for review August 28, 2026 13:19
@ddrthall
ddrthall requested a review from a team as a code owner August 28, 2026 13:19
@ddrthall
ddrthall merged commit 3007717 into master Aug 28, 2026
4 checks passed
@ddrthall
ddrthall deleted the ryanhall/AGENT-16861-reraise-transient-write-errors branch August 28, 2026 18:39
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.

2 participants