> I have faced a quite sad situation. Master was so ashamed of the code
> his worker was running, that it killed itself.
>
> Relevant config options:
>
> ------8<------8<------8<------8<------8<------8<------
> master = true
> ; nginx kills connection after 60s
> harakiri = 65
> harakiri-verbose = true
> reload-mercy = 65
>
> workers = 4
> threads = 25
>
> lazy = true
> ; kill workers if there are no requests at all for 90 seconds keeping one
> ; worker alive as a `hot cache`
> cheaper = 1
> idle = 90
> ------8<------8<------8<------8<------8<------8<------
>
> I suspect `cheaper` option. I see following in logs:
>
> *** HARAKIRI ON WORKER 3 (pid: 0) ***
> Thu Feb  9 11:53:59 2012 - uWSGI worker 1 screams: UAAAAAAH my master
> died, i will follow him...
> Thu Feb  9 11:53:59 2012 - uWSGI worker 1 screams: UAAAAAAH my master
> died, i will follow him...
>
> It's quite brutal to kill(0, SIGBLAH), "If pid equals 0, then sig is
> sent to every process in the process group of the calling process."
> I've not seen same issue after following patch:
>
> ------8<------8<------8<------8<------8<------8<------
> diff -r 3f88229ad41d master.c
> --- a/master.c        Wed Feb 01 17:55:33 2012 +0100
> +++ b/master.c        Sun Feb 12 14:50:38 2012 +0700
> @@ -1671,6 +1671,7 @@
>                       if (uwsgi.workers[uwsgi.mywid].cheaped == 1) {
>                               uwsgi.workers[uwsgi.mywid].pid = 0;
>                               uwsgi_log("uWSGI worker %d cheaped.\n", 
> uwsgi.mywid);
> +                             uwsgi.workers[uwsgi.mywid].harakiri = 0;
>                               continue;
>                       }
>                       gettimeofday(&last_respawn, NULL);
> ------8<------8<------8<------8<------8<------8<------
>
> I'm unsure if it's correct way to patch the code, but it seems to be
> so. Do you have any comments?
>


The patch is good, and what you have found is an ugly race condition
happening with cheaper + threading.

I have applied it (with minor addition) to both stable and development tree

http://projects.unbit.it/uwsgi/changeset/d25d42a2c38dee8c39478ea17f5243caf13b7745

Many thanks, and good job finding such hidden bug.


-- 
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to