ramkrishanbhatt / modwsgi

Automatically exported from code.google.com/p/modwsgi
0 stars 0 forks source link

In daemon mode, signals are being blocked in exec'd processes. #87

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
As per discussion in:

  http://groups.google.com/group/modwsgi/browse_frm/thread/c29ad9fa9f516a93?hl=en

and a previous older report which was discounted at time due to lack of 
information, processes which are exec'd from mod_wsgi 
daemon process to perform work are inheriting a signal mask which blocks 
reception of various signals.

This is because mod_wsgi daemon mode blocks off signals so that they  aren't 
handled in the worker threads dealing with 
requests. Signals  are then waited upon and dealt with in main thread which 
also handles  ensuring process shutdown. Problem is 
that the blocking of signals for the worker threads is  being inherited across 
a fork/exec which isn't what was expected.

Fixing this issue will be tricky and will need some rework of  mod_wsgi, with a 
movement away from relying solely on signals for 
ensuring daemon process shutdown to a more complicated arrangement  using a 
pipe of death. I was looking at using a pipe of 
death anyway  as only safe way of doing things when introduce transient 
processes. 

Note that this issue may need to be fixed in order to allow implementation of 
cpu limits with an orderly shutdown.

Original issue reported on code.google.com by Graham.Dumpleton@gmail.com on 8 Jun 2008 at 1:46

GoogleCodeExporter commented 8 years ago
Fix commited in revision 1201 of subversion trunk for 3.0. Now use a pipe, 
which signal handler writes character 
to, with main thread doing a poll on the pipe waiting for shutdown.

Original comment by Graham.Dumpleton@gmail.com on 20 Feb 2009 at 10:49

GoogleCodeExporter commented 8 years ago
Graham,

I'm running into this exact issue as discussed in your linked google groups 
page.  Is
this fix stable enough to compile and put into production?

Thanks.

Original comment by andrew.s...@gmail.com on 20 Feb 2009 at 5:03

GoogleCodeExporter commented 8 years ago
Have you tested it on a development system to see if it even solves the problem.

The fix made theoretically should fix the problem, but I haven't actually run a 
test to confirm that yet.

If can get some confirmation or when I get a chance to test myself properly, 
then will look at back porting it to 
2.X branch. The 2.X branch should be reasonably safe to use, unless your intent 
was just to apply the fix.

Original comment by Graham.Dumpleton@gmail.com on 21 Feb 2009 at 9:57

GoogleCodeExporter commented 8 years ago
Back ported to mod_wsgi 2.X branch in revision 1203.

Also attached diff which should work for mod_wsgi 2.3 if want to apply just 
this change.

Change has been tested and does fix original problem. No issues yet seen with 
daemon processed not shutting 
down as expected.

Original comment by Graham.Dumpleton@gmail.com on 21 Feb 2009 at 11:04

Attachments:

GoogleCodeExporter commented 8 years ago
Version 2.4 of mod_wsgi now released.

Original comment by Graham.Dumpleton@gmail.com on 11 Apr 2009 at 10:25