Skip to content

Mark sender and timer threads as fork safe for Puma#315

Open
joshuay03 wants to merge 2 commits into
DataDog:masterfrom
joshuay03:mark-sender-thread-as-fork-safe
Open

Mark sender and timer threads as fork safe for Puma#315
joshuay03 wants to merge 2 commits into
DataDog:masterfrom
joshuay03:mark-sender-thread-as-fork-safe

Conversation

@joshuay03
Copy link
Copy Markdown

@joshuay03 joshuay03 commented Jul 24, 2025

We're in the process of enabling Puma's preload_app! config at @buildkite. When auditing threads spawned during boot, Puma flagged this gem's sender thread as potentially not fork safe. However, based on the documentation for this gem and the implementation of Datadog::Statsd::Sender#add, the sender thread appears fork safe to me. The same reasoning applies to the Statsd Timer thread used when buffer_flush_interval is configured, since Sender#add also restarts the flush timer after a fork.

This PR adds a :fork_safe thread variable to both threads, which Puma uses to exclude them from its safety reporting, so that anyone else auditing their threads this way won't see false positives from this gem.

Refs:

@joshuay03 joshuay03 requested a review from a team as a code owner July 24, 2025 06:47
@joshuay03 joshuay03 moved this to In Progress / Pending Review in Open Source Jul 24, 2025
@joshuay03 joshuay03 force-pushed the mark-sender-thread-as-fork-safe branch from 2371e4a to c70dfad Compare July 24, 2025 07:36
Comment thread spec/statsd/sender_spec.rb Outdated
@joshuay03 joshuay03 force-pushed the mark-sender-thread-as-fork-safe branch from c70dfad to f672101 Compare September 23, 2025 20:59
@joshuay03 joshuay03 requested a review from nightpool September 30, 2025 02:12
Comment thread lib/datadog/statsd/sender.rb
@joshuay03 joshuay03 force-pushed the mark-sender-thread-as-fork-safe branch 3 times, most recently from a769866 to e0846eb Compare February 14, 2026 20:22
@joshuay03 joshuay03 requested a review from marcotc March 13, 2026 08:40
@joshuay03
Copy link
Copy Markdown
Author

Bump 🙏🏽

@carlosroman
Copy link
Copy Markdown
Contributor

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0846eb6e0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread lib/datadog/statsd/sender.rb
@carlosroman
Copy link
Copy Markdown
Contributor

@joshuay03 Let me fix the CI so that we can run the tests for this PR. Sorry about that.

@joshuay03 joshuay03 changed the title Mark sender thread as fork safe for Puma Mark sender and timer threads as fork safe for Puma May 19, 2026
@joshuay03 joshuay03 force-pushed the mark-sender-thread-as-fork-safe branch from 43436b6 to f9a43b0 Compare May 19, 2026 04:07
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.

4 participants