Skip to content

fix(socket sink): reconnect and retry on datagram socket send failure#24834

Draft
thomasqueirozb wants to merge 3 commits intomasterfrom
fix/datagram-reconnect-on-send-failure
Draft

fix(socket sink): reconnect and retry on datagram socket send failure#24834
thomasqueirozb wants to merge 3 commits intomasterfrom
fix/datagram-reconnect-on-send-failure

Conversation

@thomasqueirozb
Copy link
Contributor

Summary

When a UDP or Unix datagram socket send() fails (e.g. "Destination address required" / OS error 89 due to DNS resolution changes), send_datagrams() would continue consuming events from the input stream and attempting to send them on the same broken socket, silently dropping all remaining events. The outer run() loop already handles reconnection but send_datagrams() never returned early to let that happen.

This adopts the same pre-encode + peek/consume pattern used by TCP and Unix stream sinks: events are encoded before the peekable stream boundary so send_datagrams() can peek without consuming. On socket errors the event stays in the stream and is retried after reconnection with a fresh socket (and fresh DNS resolution). Chunking errors still consume and error the event since reconnecting wouldn't help.

Vector configuration

[sinks.udp_out]
type = "socket"
mode = "udp"
address = "some-host:5000"
encoding.codec = "json"

How did you test this PR?

  • cargo clippy --no-default-features --features "sinks-socket" -- -D warnings
  • cargo nextest run --workspace --no-default-features --features "sinks-socket" sinks::socket (7 passed)
  • cargo nextest run --workspace --no-default-features --features "sinks-socket" sinks::util::unix (2 passed)

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

NA

@github-actions github-actions bot added the domain: sinks Anything related to the Vector's sinks label Mar 3, 2026
@thomasqueirozb thomasqueirozb changed the title fix(sinks): reconnect and retry on datagram socket send failure fix(socket sink): reconnect and retry on datagram socket send failure Mar 3, 2026
@thomasqueirozb thomasqueirozb added the sink: socket Anything `socket` sink related label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: sinks Anything related to the Vector's sinks sink: socket Anything `socket` sink related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant