[Bug 1481737] [NEW] HAProxy init script does not work correctly with nbproc configuration option

Launchpad Bug Tracker 1481737 at bugs.launchpad.net
Thu Sep 24 10:06:43 UTC 2015


You have been subscribed to a public bug by Louis Bouchard (louis-bouchard):

[SRU justification]
The sysVinit script does not completely stop processes when nbproc > 1

[Impact]
Stopping haproxy without this fix leaves all but one process running

[Fix]
Use temporary pidfile in a loop containing one single PID as the --pid option is not available for start-stop-daemon.

[Test Case]
Set nbproc > 4 in /etc/haproxy/haproxy.cfg
resart haproxy & verify that there is more than one haproxy process
Run :
$ ps aux | grep haproxy | grep -v grep | wc -l
4
$ service haproxy stop
$ ps aux | grep haproxy | grep -v grep | wc -l

Without the patch, the result of the last command will be 3. With the
fix, it will be 0

[Regression]
The regression risk is in the use of a temporary file instead of the start-stop-daemon option.

It has been tested with TMPDIR="/tmp/My Dir" to check for spaces in
directory names.

[Original description of the problem]
In case you have more than one process enabled in the haproxy config, the init script fails to stop all of those processes.
So to clarify you need to have this in your haproxy.cfg:

"""
...
global
        maxconn         32000
        ulimit-n        65536
        user            haproxy
        group           haproxy
        nbproc          2

...
"""

the problem is more visible if you set the nbproc to higher number.

service haproxy stop --> will only stop on of the haproxy processes.

The problem is so that start-stop-daemon can't handle pid files with multiple lines. Only stopping the first one. HAProxy does write all the pids started by itself into the pid file, so the problem is not in HAProxy, but in the start-stop-daemon or more likely in the init scrip of haproxy.
One solution or workaround is to remove pidfile option of start-stop-daemon in the init script, than it wil work as killall and will stop the haproxy processes properly.

To proof you can try this sequence:

service haproxy start #if its not running
ps ax | grep haproxy | grep -v grep | wc -l #this should report 2
service haproxy restart
ps ax | grep haproxy | grep -v grep | wc -l #this will report 3

The workaround as a diff:
root at ubi1:/opt# diff /etc/init.d/haproxy /etc/init.d/haproxy.orig
62c62
<               --retry 5 --exec $HAPROXY || ret=$?
---
>               --retry 5 --pidfile $PIDFILE --exec $HAPROXY || ret=$?

extra infos:
root at ubi1:/opt# lsb_release -rd
Description:    Ubuntu 14.04.3 LTS
Release:        14.04

root at ubi1:/opt# apt-cache policy haproxy
haproxy:
  Installed: 1.4.24-2ubuntu0.2
  Candidate: 1.4.24-2ubuntu0.2
  Version table:
     1.5.3-1~ubuntu14.04.1 0
        100 http://us.archive.ubuntu.com/ubuntu/ trusty-backports/main amd64 Packages
 *** 1.4.24-2ubuntu0.2 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     1.4.24-2 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

** Affects: haproxy (Ubuntu)
     Importance: Undecided
         Status: Invalid

** Affects: haproxy (Ubuntu Trusty)
     Importance: Medium
     Assignee: Louis Bouchard (louis-bouchard)
         Status: In Progress


** Tags: haproxy needs-upstream-report
-- 
HAProxy init script does not work correctly with nbproc configuration option
https://bugs.launchpad.net/bugs/1481737
You received this bug notification because you are a member of Ubuntu Sponsors Team, which is subscribed to the bug report.



More information about the Ubuntu-sponsors mailing list