SIGWINCH not working on second on-the-fly binary upgrade

Hi,

I was trying to upgrade nginx from 1.0.9 to 1.0.10 on-the-fly, using
the process described on the wiki[1], but it looks like it is ignoring
the SIGWINCH signal I send to it.

bender:~# ps ax -H | grep nginx
31603 pts/2 S+ 0:00 grep nginx
32606 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
32607 ? S 9:47 nginx: worker process
31309 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31310 ? S 0:00 nginx: worker process
bender:~# kill -WINCH 32606 # 32606 is the 1.0.9 master process, 31309
is the 1.0.10 master process
bender:~# ps ax -H | grep nginx
31605 pts/2 S+ 0:00 grep nginx
32606 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
32607 ? S 9:47 nginx: worker process
31309 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31310 ? S 0:00 nginx: worker process

After a quick look at the code, it looks like this happened because
the 1.0.9 process I am running was started during a previous
1.0.7->1.0.9 on-the-fly upgrade, and the 1.0.9 master process now
thinks it is not daemonized (ngx_daemonized is not set on
initialization if ngx_inherited is set).

I have easily reproduced it by killing nginx completely, making a
on-the-fly 1.0.10->1.0.10 executable upgrade twice. On the first try,
SIGWINCH works; after the first upgrade, SIGWINCH stops working. Full
shell session showing the bug is pasted at the end of my message.

[1]
http://wiki.nginx.org/CommandLine#Upgrading_To_a_New_Binary_On_The_Fly


Eduardo

Shell session:

bender:~# ps ax -H | grep nginx
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31684 pts/5 S+ 0:00 grep nginx
bender:~# /usr/local/nginx/sbin/nginx
bender:~# ps ax -H | grep nginx
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31689 pts/5 S+ 0:00 grep nginx
31686 ? Ss 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31687 ? S 0:00 nginx: worker process
bender:~# kill -USR2 31686
bender:~# ps ax -H | grep nginx
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31693 pts/5 S+ 0:00 grep nginx
31686 ? Ss 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31687 ? S 0:00 nginx: worker process
31690 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31691 ? S 0:00 nginx: worker process
bender:~# kill -WINCH 31686
bender:~# ps ax -H | grep nginx
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31695 pts/5 S+ 0:00 grep nginx
31686 ? Ss 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31690 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31691 ? S 0:00 nginx: worker process
bender:~# echo SIGWINCH worked on the first process
SIGWINCH worked on the first process
bender:~# kill -QUIT 31686
bender:~# ps ax -H | grep nginx
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31697 pts/5 S+ 0:00 grep nginx
31690 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31691 ? S 0:00 nginx: worker process
bender:~# kill -USR2 31690
bender:~# ps ax -H | grep nginx
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31705 pts/5 S+ 0:00 grep nginx
31690 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31691 ? S 0:00 nginx: worker process
31702 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31703 ? S 0:00 nginx: worker process
bender:~# kill -WINCH 31690
bender:~# ps ax -H | grep nginx
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31709 pts/5 S+ 0:00 grep nginx
31690 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31691 ? S 0:00 nginx: worker process
31702 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31703 ? S 0:00 nginx: worker process
bender:~# kill -WINCH 31690
bender:~# ps ax -H | grep nginx
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31711 pts/5 S+ 0:00 grep nginx
31690 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31691 ? S 0:00 nginx: worker process
31702 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31703 ? S 0:00 nginx: worker process
bender:~# echo PID 31690 is ignoring SIGWINCH signals
PID 31690 is ignoring SIGWINCH signals
bender:~# kill -QUIT 31690
bender:~# ps ax -H | grep nginx
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31713 pts/5 S+ 0:00 grep nginx
31702 ? S 0:00 nginx: master process
/usr/local/nginx/sbin/nginx
31703 ? S 0:00 nginx: worker process

Nice find, I think I was experiencing a similar issue with upgrading on
the
fly from 1.1.7 to 1.1.9.

On Tue, Nov 15, 2011 at 11:38 AM, Eduardo Habkost
[email protected]wrote:

32607 ? S 9:47 nginx: worker process
31309 ? S 0:00 nginx: master process
on-the-fly 1.0.10->1.0.10 executable upgrade twice. On the first try,

/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx
31691 ? S 0:00 nginx: worker process
bender:~# kill -USR2 31690
bender:~# kill -WINCH 31690
bender:~# kill -WINCH 31690
bender:~# echo PID 31690 is ignoring SIGWINCH signals


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

Ilan B.
Chief Technology Officer
Time4Learning.com

6300 NE 1st Ave., Suite 203
Ft. Lauderdale, FL 33334
(954) 771-0914

http://www.twitter.com/time4learning
http://www.facebook.com/Time4Learning

Time4Learning.com - Online interactive curriculum for home use, PreK-8th
Grade.
Time4Writing.com - Online writing tutorials for high, middle, and
elementary school students.
Time4Learning.net - A forum to chat with parents online about kids,
education, parenting and more.
spellingcity.com - Online vocabulary and spelling activities for
teachers,
parents and students.

Verified here as well, I am upgrading by sending QUIT to the old master
process as WINCH does not work.

Boyko

I mean 1.1.8.

On Tue, Nov 15, 2011 at 11:40 AM, Ilan B.
[email protected]wrote:

the SIGWINCH signal I send to it.
is the 1.0.10 master process
the 1.0.9 process I am running was started during a previous
http://wiki.nginx.org/CommandLine#Upgrading_To_a_New_Binary_On_The_Fly
31684 pts/5 S+ 0:00 grep nginx
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
bender:~# ps ax -H | grep nginx
31705 pts/5 S+ 0:00 grep nginx
31709 pts/5 S+ 0:00 grep nginx
31711 pts/5 S+ 0:00 grep nginx
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script

Ft. Lauderdale, FL 33334
education, parenting and more.
spellingcity.com - Online vocabulary and spelling activities for
teachers, parents and students.

Ilan B.
Chief Technology Officer
Time4Learning.com

6300 NE 1st Ave., Suite 203
Ft. Lauderdale, FL 33334
(954) 771-0914

http://www.twitter.com/time4learning
http://www.facebook.com/Time4Learning

Time4Learning.com - Online interactive curriculum for home use, PreK-8th
Grade.
Time4Writing.com - Online writing tutorials for high, middle, and
elementary school students.
Time4Learning.net - A forum to chat with parents online about kids,
education, parenting and more.
spellingcity.com - Online vocabulary and spelling activities for
teachers,
parents and students.

Hello!

On Tue, Nov 15, 2011 at 02:38:31PM -0200, Eduardo Habkost wrote:

I was trying to upgrade nginx from 1.0.9 to 1.0.10 on-the-fly, using
the process described on the wiki[1], but it looks like it is ignoring
the SIGWINCH signal I send to it.

[…]

After a quick look at the code, it looks like this happened because
the 1.0.9 process I am running was started during a previous
1.0.7->1.0.9 on-the-fly upgrade, and the 1.0.9 master process now
thinks it is not daemonized (ngx_daemonized is not set on
initialization if ngx_inherited is set).

I have easily reproduced it by killing nginx completely, making a
on-the-fly 1.0.10->1.0.10 executable upgrade twice. On the first try,
SIGWINCH works; after the first upgrade, SIGWINCH stops working. Full
shell session showing the bug is pasted at the end of my message.

Yes, thank you, this is a bug introduced in 1.1.1/1.0.9.

As a workaround SIGQUIT to old master process may be used (it
doesn’t allow to revive old master, but allow upgrade).

The following patch should fix this:

diff --git a/src/core/nginx.c b/src/core/nginx.c
— a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -374,6 +374,10 @@ main(int argc, char *const *argv)
ngx_daemonized = 1;
}

  • if (ngx_inherited) {
  •    ngx_daemonized = 1;
    
  • }

#endif

 if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) {

Maxim D.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs