Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent ENOBUFS errors by skipping UDP send buffer size configuration #392

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

pedro-stanaka
Copy link
Contributor

@pedro-stanaka pedro-stanaka commented Jan 13, 2025

✅ What

  • Prevents ENOBUFS errors by making UDP connections skip send buffer size configuration
  • Improves UDP socket creation by using the correct address family
  • Updates error message to be more accurate

🤔 Why

When using UDP connections, the previous implementation attempted to set the socket's send buffer size. This could lead to Errno::ENOBUFS errors in certain environments, particularly when the system is under high load or has strict buffer size limitations. By skipping the buffer size configuration for UDP connections specifically, we prevent these errors while maintaining the original functionality for other connection types.

Validation

Made sure that we dont see any ENOBUFS in benchmarks (even though this might be related to network layer).

Checklist

  • I documented the changes in the CHANGELOG file.

@pedro-stanaka pedro-stanaka force-pushed the fix/udp-connection-do-not-set-sendbuf branch 2 times, most recently from 9c43823 to 914ea90 Compare January 13, 2025 16:01
The previous implementation attempted to set the UDP socket's send buffer
size, which could lead to ENOBUFS errors in some environments. This change:
- Overrides setup_socket in UDPConnection to skip buffer size configuration
- Improves socket creation by using the correct address family
- Updates error message to be more accurate ("Failed to setup socket")

This prevents potential buffer-related errors while maintaining the original
functionality for other connection types.
@pedro-stanaka pedro-stanaka force-pushed the fix/udp-connection-do-not-set-sendbuf branch from 914ea90 to abed4ff Compare January 13, 2025 16:25
Copy link
Contributor

@ahayworth ahayworth left a comment

Choose a reason for hiding this comment

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

Mechanically speaking, this PR is fine - I don't see any obvious errors.

I think this puts us back in the situation of potentially allowing packets that are too big to fit in a buffer? But ... I'm not certain.

I think this is okay though.

def socket
@socket ||= begin
udp_socket = UDPSocket.new
family = Addrinfo.udp(host, port).afamily
udp_socket = UDPSocket.new(family)
Copy link
Contributor

Choose a reason for hiding this comment

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

ipv6 support? cool!

Choose a reason for hiding this comment

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

This seems to breaking our stats logging to Datadog. We're on a k8s stack so I'm guessing it's something to do with the IPv6 support? We're investigating now.

Choose a reason for hiding this comment

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

We suspect it was due to us using a socat proxy bound to IPv4 only. We proxy through a central Datadog agent that forwards our stats to Datadog.

It will take a bit to update and test across our environments to confirm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Feel free to put up a PR in case it turns out to be an issue.

@pedro-stanaka pedro-stanaka merged commit 6fd8c49 into main Jan 14, 2025
11 checks passed
@adrianna-chang-shopify
Copy link

Is there any way we could write a regression test here / in Shopify/shopify so that we can verify we won't run into the same problem we ran into when we tried to deploy v 3.9.8?

Comment on lines +23 to +26
# From Ruby >= 3.5, logger is not part of the stdlib anymore
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.5")
gem "logger"
end

Choose a reason for hiding this comment

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

I don't see anything about this in the 3.4 release notes, was this communicated somewhere?

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.

5 participants