2

My django+ngnix application server goes down frequently without proper information. So I checked the logs and can see the process goes into defunct state.

3072 ? 00:18:41 uwsgi
4045 ? 01:00:56 uwsgi Defunct

So restarted the process and worked for now.

Anyone know the reason why the server goes down frequently, uwsgi dies? also is there any way to restart or recover the process if it goes into defunct state?

Thanks in Advance.

John Hascall
  • 9,176
  • 6
  • 48
  • 72
Joseph Davis
  • 118
  • 1
  • 14

2 Answers2

2

A <Defunct> process is dead. It's just hanging around until its parent process retrieves its exit status. There is nothing that can be done to it.

If you kill its parent, then it is re-parented to the init process (process #1) which will retrieve its status (and discard it), which will cause the defunct process to vanish from ps

John Hascall
  • 9,176
  • 6
  • 48
  • 72
  • Thanks John Hascall. Do you know the reason why the process goes into defunct state? Before upgrading the system, It seems like most of the resource is in used state(99%). So I upgraded into 16GB. Also the celery process have some issues, its delayed to process the tasks in the queue. database server also uses 99% of the resource. Is this leads to defunct state? – Joseph Davis Jan 09 '16 at 05:22
  • Defunct just means its parent process hasn't retrieved its state. Probably this means the parent process is stuck or otherwise malfunctioning. – John Hascall Jan 09 '16 at 05:23
  • Fetching large amount of data cause this issue? our db is postgres. – Joseph Davis Jan 09 '16 at 05:32
  • Maybe. Could be lots of things. Hard to tell from here. – John Hascall Jan 09 '16 at 05:36
  • Okay. It will be good if you can list some of the possibilities – Joseph Davis Jan 15 '16 at 07:29
2

A defunct process is a zombie process and such process has exited from system but it's exit code is not received by its parent process because its parent has exited before it hence its entry is present in ps table.

But such processes does not consume your resources.

You can avoid this by using a wait condition in its parent process.

So that parent will wait for the child to exit successfully and then parent will exit from system.