Apache – How to Diagnose Stuck Worker Process in Apache and mod_wsgi

apache-2.2mod-wsgimpm-workerpython

I am running Apache 2.2 with mod_wsgi, Python 2.7 and mpm_worker. Occassionally, one of the worker processes gets stuck and all of it threads stop in writing state (as demostrated in the screenshot below).

This happens ~once in a day for one worker process.

I assume this is either because

  • Some internal problem in Apache

  • All of my Python threads inside the mod_wsgi worker process deadlock somehow

Thus far, the only remedy I have found is Apache full restart (not graceful).

I'd hope to find some pointers how to diagnose the issue what is causing it

  • Why Apace Timeout does not kill the worker threads / processes. Time timeout is one minute, but looks like those threads and workers have been running happily several hours on one request.

  • Is it possible to obtain thread dump from inside mod_wsgiand see if the Python thread themselves are somehow deadlocked

  • Any idea what could be causing this and how to remedy the situation?

Below is an screenshot showing Apache server-status where one of the worker processes (1-0) is stuck.

enter image description here

Best Answer

After turning on WSGIDaemonProcess and switching to separate daemon processes this issue has not appeared anymore, as recommended in the linked question.