Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 584410 - net-proxy/haproxy - With nbproc > 1, processes remain when restarting or stopping the service.
Summary: net-proxy/haproxy - With nbproc > 1, processes remain when restarting or stop...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Christian Ruppert (idl0r)
URL:
Whiteboard:
Keywords:
Depends on: 601540
Blocks:
  Show dependency tree
 
Reported: 2016-05-28 14:50 UTC by calimeroteknik
Modified: 2017-11-30 07:25 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
processes are not killed when restarting haproxy (haproxy-restarts.txt,4.06 KB, text/plain)
2016-05-28 14:50 UTC, calimeroteknik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description calimeroteknik 2016-05-28 14:50:49 UTC
Created attachment 435642 [details]
processes are not killed when restarting haproxy

I noticed that haproxy (1.6.5, but the other versions are affected), when run with several processes, would continue to respond to requests even after stopping the haproxy service (/etc/init.d/haproxy stop).

This is due to only one process being killed instead of all.

Of course, when restarting, the number of processes increases each time (see attachment).


My haproxy configuration contains the following:
global
  user haproxy
  group haproxy
  nbproc 4

Reproducible: always


Some insight:

~ # ps aux |grep haproxy
haproxy  29858  0.0  0.0  51504  1144 ?        Ss   16:19   0:00 /usr/bin/haproxy -D -p /var/run/haproxy.pid -f /etc/haproxy.cfg
haproxy  29859  0.0  0.0  51504  1144 ?        Ss   16:19   0:00 /usr/bin/haproxy -D -p /var/run/haproxy.pid -f /etc/haproxy.cfg
haproxy  29860  0.0  0.0  51504  1144 ?        Ss   16:19   0:00 /usr/bin/haproxy -D -p /var/run/haproxy.pid -f /etc/haproxy.cfg
haproxy  29861  0.0  0.0  51504  1144 ?        Ss   16:19   0:00 /usr/bin/haproxy -D -p /var/run/haproxy.pid -f /etc/haproxy.cfg
~ # cat /var/run/haproxy.pid
29858
29859
29860
29861
~ # 

I suspect that the bug resides in that the multiline pidfile is not handled properly by the stop function of the service. Said function must be OpenRC's default, since the service specifies none.
Comment 1 Bertrand Jacquin 2016-10-05 21:39:08 UTC
Indeed, pid file then contains one line per haproxy daemon running

# cat /var/run/haproxy.pid                                                                                                         
559
560

man 8 start-stop-daemon says

  When stopping we only stop the pid(s) listed in the pidfile

But looking at the code, only the first PID is actually read (see https://gitweb.gentoo.org/proj/openrc.git/tree/src/rc/start-stop-daemon.c#n349) and a struct pid_t is returned to caller
Comment 2 calimeroteknik 2016-12-08 23:34:28 UTC
It would seem like there is no possible option to make OpenRC's start-stop-daemon accomodate for this, see the discussion at https://bugs.gentoo.org/show_bug.cgi?id=601540

So this needs be fixed in the init.d/haproxy service script.
Comment 3 Bertrand Jacquin 2016-12-13 00:45:34 UTC
See https://github.com/gentoo/gentoo/pull/3104 for a fix proposal
Comment 4 calimeroteknik 2017-10-24 12:01:52 UTC
The bug is technically solved, however with curious error messages:

~ # /etc/init.d/haproxy stop
 * Stopping haproxy ...                               [ ok ]
 * Stopping haproxy ...                               [ ok ]
 * Stopping haproxy ...
 * start-stop-daemon: no matching processes found     [ ok ]
 * Stopping haproxy ...
 * start-stop-daemon: no matching processes found     [ ok ]
~ # pgrep -a haproxy
~ # /etc/init.d/haproxy start
 * Checking /etc/haproxy.cfg ...                      [ ok ]
 * Starting haproxy ...                               [ ok ]
~ # /etc/init.d/haproxy stop
 * Stopping haproxy ...                               [ ok ]
 * Stopping haproxy ...                               [ ok ]
 * Stopping haproxy ...
 * start-stop-daemon: no matching processes found     [ ok ]
 * Stopping haproxy ...
 * start-stop-daemon: no matching processes found     [ ok ]
~ # /etc/init.d/haproxy start
 * Checking /etc/haproxy.cfg ...                      [ ok ]
 * Starting haproxy ...                               [ ok ]
~ # 

I don't see the reason for this happening.
The parent PID of the four haproxy processes is init.
Comment 5 Patrick Lauer gentoo-dev 2017-11-30 07:25:19 UTC
The strange messages on stop are caused by multiple bugs interacting

This was fixed in commit 1016c8d09a77369c4b37e511bf6b3f03922f7c23

With older openrc versions before 0.34.11 it would kill all processes called haproxy on the second iteration due to a bug, with newer openrc it refuses to kill. The fixed init script kills the expected PIDs at last.