zombocom / puma_worker_killer

Automatically restart Puma cluster workers based on max RAM available
747 stars 77 forks source link

[ruby] <defunct> #75

Closed wellington1993 closed 5 years ago

wellington1993 commented 5 years ago

Hi,

I like that project but I've got a problem with defunct processes. After the kill action from gem, the killed ruby processes, still are presents in the process list with pid and with defunct state.

Without clean of that processes can be a problem. Images:

puma-defunct-5-htop puma-defunct-4-config puma-defunct-3-pstree puma-defunct-2 puma-defunct-1

Thanks!

wellington1993 commented 5 years ago

I have 214 defunct processes now. Isn't a big problem because the '/proc/sys/kernel/pid_max' value is 32768.

But if the processes still defuncting maybe will be a problem in the future.

I'm search and apparently the best way to free the defunct process is killing the parent process. But I don't know a secure way to do this in production environment.

Thanks!

schneems commented 5 years ago

Can you manually send a SIGTERM to those processes and have them shut down?

It seems like the issue is there is something preventing the process from shutting down which would likely be a problem in your app code instead of with puma or puma worker killer.

Try running a plain puma process with a “hello world” rack app and see if it still happens. Also make sure puma and PWK are upgraded to the latest.

For the processes that are still alive there might be ways to get them to output where they are stuck. Maybe a tool like rbtrace.

wellington1993 commented 5 years ago

Thanks @schneems

I will try rbtrace. Probably my app code and maybe related with threads use.

Closing this issue for now.