Skip to content

Leaking pipe handles on SIGUSR2 #182

@sriedel

Description

@sriedel

This may be a simple puma configuration error, since I'm just starting out with puma, but I haven't found anything in the documentation that mentions this.

I'm running puma 1.6.3 on a centos 6 server using MRI 1.9.3p327 with rails 3.2.11. My puma config file looks like this:

environment "staging"
bind "unix:///deploy_path/staging/shared/sockets/puma.sock"
threads 1,4
pidfile "/deploy_path/staging/shared/pids/puma.pid"

on_restart do
    ActiveRecord::Base.connection.close
end

Alternating between checking used filehandles and restarting puma in the shell I get the following output:

[user@server deploy_path]$ ps ax | grep puma
23302 pts/0    Sl+    0:02 ruby /deploy_path/staging/shared/bundle/ruby/1.9.1/bin/puma -C /deploy_path/staging/current/config/puma.conf
[user@server deploy_path]$ lsof -p 23302 | grep pipe
ruby    23302 user    3r  FIFO                0,8      0t0 3049293 pipe
ruby    23302 user    4w  FIFO                0,8      0t0 3049293 pipe
ruby    23302 user    9r  FIFO                0,8      0t0 3049304 pipe
ruby    23302 user   10w  FIFO                0,8      0t0 3049304 pipe
ruby    23302 user   11r  FIFO                0,8      0t0 3049305 pipe
ruby    23302 user   12w  FIFO                0,8      0t0 3049305 pipe
ruby    23302 user   14r  FIFO                0,8      0t0 3049308 pipe
ruby    23302 user   15w  FIFO                0,8      0t0 3049308 pipe
[user@server deploy_path]$ kill -USR2 23302
[user@server deploy_path]$ lsof -p 23302 | grep pipe
ruby    23302 user    3r  FIFO                0,8      0t0 3049452 pipe
ruby    23302 user    4w  FIFO                0,8      0t0 3049452 pipe
ruby    23302 user    9r  FIFO                0,8      0t0 3049304 pipe
ruby    23302 user   10w  FIFO                0,8      0t0 3049304 pipe
ruby    23302 user   11r  FIFO                0,8      0t0 3049305 pipe
ruby    23302 user   14r  FIFO                0,8      0t0 3049308 pipe
ruby    23302 user   15w  FIFO                0,8      0t0 3049308 pipe
ruby    23302 user   16r  FIFO                0,8      0t0 3049461 pipe
ruby    23302 user   17w  FIFO                0,8      0t0 3049461 pipe
ruby    23302 user   18r  FIFO                0,8      0t0 3049462 pipe
ruby    23302 user   19w  FIFO                0,8      0t0 3049462 pipe
ruby    23302 user   20r  FIFO                0,8      0t0 3049463 pipe
ruby    23302 user   21w  FIFO                0,8      0t0 3049463 pipe
[user@server deploy_path]$ kill -USR2 23302
[user@server deploy_path]$ lsof -p 23302 | grep pipe
ruby    23302 user    3r  FIFO                0,8      0t0 3049530 pipe
ruby    23302 user    4w  FIFO                0,8      0t0 3049530 pipe
ruby    23302 user    9r  FIFO                0,8      0t0 3049304 pipe
ruby    23302 user   10w  FIFO                0,8      0t0 3049304 pipe
ruby    23302 user   11r  FIFO                0,8      0t0 3049305 pipe
ruby    23302 user   14r  FIFO                0,8      0t0 3049308 pipe
ruby    23302 user   15w  FIFO                0,8      0t0 3049308 pipe
ruby    23302 user   16r  FIFO                0,8      0t0 3049461 pipe
ruby    23302 user   17w  FIFO                0,8      0t0 3049461 pipe
ruby    23302 user   18r  FIFO                0,8      0t0 3049462 pipe
ruby    23302 user   20r  FIFO                0,8      0t0 3049463 pipe
ruby    23302 user   21w  FIFO                0,8      0t0 3049463 pipe
ruby    23302 user   22r  FIFO                0,8      0t0 3049540 pipe
ruby    23302 user   23w  FIFO                0,8      0t0 3049540 pipe
ruby    23302 user   24r  FIFO                0,8      0t0 3049541 pipe
ruby    23302 user   25w  FIFO                0,8      0t0 3049541 pipe
ruby    23302 user   26r  FIFO                0,8      0t0 3049542 pipe
ruby    23302 user   27w  FIFO                0,8      0t0 3049542 pipe

I'm not opening connections to anywhere other than activerecord at the moment from within my app.

It looks to me like puma is opening pipes to communicate with itself (between threads?) and the pipes don't get closed after a restart. Checking with ps -efL does show that the old threads die on a SIGUSR2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions