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

Add lock to avoid problematic API calls such as getaddrinfo during fork #3815

Open
ivoanjo opened this issue Jul 30, 2024 · 0 comments
Open
Labels
community Was opened by a community member feature-request A request for a new feature or change to an existing one

Comments

@ivoanjo
Copy link
Member

ivoanjo commented Jul 30, 2024

Is your feature request related to a problem? Please describe.

In #3015, we identified an issue where dd-trace-rb background threads calling getaddrinfo at the same time as a Ruby application is trying to fork (e.g. Resque) could cause the underlying C library to get stuck in an inconsistent state, leading to deadlocks.

We documented in https://docs.datadoghq.com/tracing/trace_collection/dd_libraries/ruby/#resque-workers-hang-on-exit our recommended workaround for this issue.

Describe the goal of the feature

Recently in #3015 (comment) the issue came up of protecting these problematic calls with a lock, similar to https://bugs.ruby-lang.org/issues/20590 / ruby/ruby#10864 .

Such a mechanism should make dd-trace-rb work out-of-the-box in every situation, avoiding the problematic case.

It looks like Ruby 3.4 might have such a feature built-in, but I do think it makes sense to have our own as:

  • We'll be supporting customers with Ruby < 3.4 for a looong time still
  • Any calls done directly via e.g. libdatadog wouldn't be protected by the Ruby VM mechanism

Describe alternatives you've considered

There's a longer discussion in #3015 but the other alternatives are closer to "workarounds" than actual solutions to the underlying problem.

Additional context

N/A

How does datadog help you?

N/A

@ivoanjo ivoanjo added feature-request A request for a new feature or change to an existing one community Was opened by a community member labels Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Was opened by a community member feature-request A request for a new feature or change to an existing one
Projects
None yet
Development

No branches or pull requests

1 participant