puma: Puma hangs on shutting down workers when received SIGINT

Steps to reproduce

bundle exec puma -C config/puma.rb

# in another terminal
kill -SIGINT {puma pid}

Expected behavior

[72484] Use Ctrl-C to stop
[72484] - Worker 0 (pid: 72516) booted, phase: 0
[72484] - Worker 1 (pid: 72517) booted, phase: 0
[72484] - Gracefully shutting down workers...
[72484] === puma shutdown: 2018-11-08 17:19:54 +0800 ===
[72484] - Goodbye!

Actual behavior

Workers are already shut down, but the cluster master hanged on Process.waitpid.

However, if I press ctrl+c after puma hanged , it terminated correctly.

[72484] Use Ctrl-C to stop
[72484] - Worker 0 (pid: 72516) booted, phase: 0
[72484] - Worker 1 (pid: 72517) booted, phase: 0
[72484] - Gracefully shutting down workers...

System configuration

Operating System: macOS 10.14.1 Ruby version: 2.5.3 Rails version: 5.2.1 Puma version: 3.12.0 Bundle version: 1.16.6

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 51 (34 by maintainers)

Commits related to this issue

Most upvoted comments

This sounds like a bug in ruby 2.6.

Maintainers are meeting tomorrow, I would expect a release Soon ™.

Nice, can anyone see if #1674 (comment) still reproduces?

I’ve had this problem for months (since updating to ruby 2.6) on my machine, running under the conditions in https://github.com/puma/puma/issues/1674#issuecomment-474704874.

3.12.1 does not fix the problem for me but I’m running my rails app on master now (with this in my gemfile: gem 'puma', github: 'puma/puma') and I don’t see this anymore. I believe it got fixed in this commit https://github.com/puma/puma/commit/c637ff0d07a8f20040cabc9b4bb758a2a931edce, because I started running on master with good results just after that was committed.

I can reproduce in a new rails app using the same configuration that @atitan described but I’m not able to reproduce under test conditions or using a bare rack app:

# config.ru
run lambda { |env| [200, {'Content-Type'=>'text/plain'}, ["Hello Rack!"]] }
# puma_config.rb
threads 4, 4
workers 2
environment "development"
preload_app!
# Gemfile
source 'https://rubygems.org'

gem 'puma', github: 'puma/puma'
gem 'rack'

@mltsy have you tested 2.5.5? afaik Ruby 2.5.5 was released to handle the regression in 2.5.4