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
Fix deadlock issue in thread pool #2656
Conversation
@wjordan Any thoughts on if it'd be possible to write a test for this? |
@cjlarose Do you think there's any chance this could be merged and released this week? This bug is affecting our production servers and I'd much rather do a clean Puma upgrade rather than monkey patch my fix in. Totally understand if that doesn't work for you though. |
Related to the comment at #2656 (review) [ci skip]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reviewed the changes and this looks great. I'm comfortable merging without a regression test given the nature of the problem.
@olivierbellone I'm comfortable merging, but I can't guarantee a release this week. I'll bring it up with the team, but recall that you can always pull dependencies directly from |
@cjlarose Thanks! Appreciate the quick merge. Using an untagged version is unfortunately not an option for us, but I'll figure something out. |
Related to the comment at #2656 (review) [ci skip]
@olivierbellone This change is available in Puma 5.4.0 now. |
Awesome! Thank you very much. |
Related to the comment at puma#2656 (review) [ci skip]
Description
Fix deadlock issue in thread pool.
This deadlock can happen when a thread is being trimmed, if the main server thread has already accepted a new incoming request and is waiting for the thread pool to not be full.
I was unable to write a test for this (race conditions are hard to reproduce!), but I was able to confirm this is a regression introduced in 5.0 by #2220. Previously, Puma did call
not_full.signal
when a thread was being trimmed: https://github.com/puma/puma/blob/v4.3.8/lib/puma/thread_pool.rb#L109.I'm happy to add a test if anyone has suggestions for how to write one :)
Fixes #2655.
Your checklist for this pull request
[ci skip]
to the title of the PR.#issue
" to the PR description or my commit messages.