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

Louis Bouchard louis.bouchard at canonical.com
Thu Sep 24 09:24:37 UTC 2015


** Description changed:

+ [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
+         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 
+ 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
+   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

** Patch added: "lp1494141_fix_stop_failure.debdiff"
   https://bugs.launchpad.net/ubuntu/+source/haproxy/+bug/1481737/+attachment/4473139/+files/lp1494141_fix_stop_failure.debdiff

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to the bug report.
https://bugs.launchpad.net/bugs/1481737

Title:
  HAProxy init script does not work correctly with nbproc configuration
  option

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/haproxy/+bug/1481737/+subscriptions



More information about the Ubuntu-server-bugs mailing list