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

Puma 6.2.1 warns about threads started in app boot #170

Closed
victorfgs opened this issue Apr 19, 2023 · 1 comment · Fixed by #215 or #216
Closed

Puma 6.2.1 warns about threads started in app boot #170

victorfgs opened this issue Apr 19, 2023 · 1 comment · Fixed by #215 or #216

Comments

@victorfgs
Copy link

Hi there,

Ever since the 5.x.x release, Puma detects and warns threads that are started in app boot (before the forking process) as you can see here. I am currently seeing the judoscale gem as one of those threads in my app(I think the thread that reports web metrics are instantiated once in the Runner process when running in cluster mode?)

It seems to me that this thread should be marked as fork safe as it was on rails connection pooling since Puma should not be worried about it.

Is my analysis correct? Is there something that I can help to fix this warning?

@adamlogic
Copy link
Collaborator

I think you're right that we can mark the thread as fork-safe, since we'll detect if the PID changes and start a separate reporter thread for each fork.

def started?
@pid == Process.pid
end

I swear we've had this discussion before, but I can't find any history of it. 🤔

carlosantoniodasilva added a commit that referenced this issue Sep 9, 2024
This prevents the Reporter thread from generating warnings with puma,
which has been warning on any threads created before forking.

The Reporter thread is aware of forking by keeping the current `pid`
around, and initializing another thread if the `pid` changes. It means
we still have a running Reporter on the main puma process in this case,
plus one for each forked process (if running in cluster mode, in case of
puma.)

References:
rails/rails#40399
puma/puma#2475
https://github.com/puma/puma/releases/tag/v5.1.0

Closes #170
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants