Please backport haproxy 1.5.14-1ubuntu0.15.10.1 from wily-updates
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
trusty-backports |
Fix Released
|
Medium
|
Unassigned |
Bug Description
On a new installation of Ubuntu 14.04.3 LTS I installed HAProxy 1.5 from trusty-backports (1.5.4-
When I restarted HAProxy, I got random HTTP 503 although the backend servers were all working fine. By checking netstat, I saw that HAProxy was listening multiple times on the frontend ports.
It seems that the init script coming with the installation does not work correctly. The processes are not terminated correctly when using stop (or restart, in this matter, either).
Only with a kill I was able to correctly terminate the HAProxy processes.
The following output should show more clarity:
root@mylinux:~# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 4653/haproxy
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 4221/haproxy
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 956/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 855/sshd
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 4653/haproxy
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 4221/haproxy
tcp 0 0 0.0.0.0:8099 0.0.0.0:* LISTEN 4653/haproxy
tcp 0 0 0.0.0.0:8099 0.0.0.0:* LISTEN 4221/haproxy
tcp6 0 0 :::22 :::* LISTEN 855/sshd
root@mylinux:~# service haproxy stop
* Stopping haproxy haproxy [ OK ]
root@mylinux:~# service haproxy status
haproxy not running.
root@mylinux:~# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 4653/haproxy
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 4221/haproxy
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 956/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 855/sshd
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 4653/haproxy
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 4221/haproxy
tcp 0 0 0.0.0.0:8099 0.0.0.0:* LISTEN 4653/haproxy
tcp 0 0 0.0.0.0:8099 0.0.0.0:* LISTEN 4221/haproxy
tcp6 0 0 :::22 :::* LISTEN 855/sshd
root@mylinux:~# killall haproxy
root@mylinux:~# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 956/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 855/sshd
tcp6 0 0 :::22 :::* LISTEN 855/sshd
root@mylinux:~# service haproxy start
* Starting haproxy haproxy [ OK ]
root@mylinux:~# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 8205/haproxy
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 956/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 855/sshd
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 8205/haproxy
tcp 0 0 0.0.0.0:8099 0.0.0.0:* LISTEN 8205/haproxy
tcp6 0 0 :::22 :::* LISTEN 855/sshd
root@mylinux:~# service haproxy restart
* Restarting haproxy haproxy [ OK ]
root@nzzad-
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 8286/haproxy
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 8205/haproxy
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 956/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 855/sshd
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 8286/haproxy
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 8205/haproxy
tcp 0 0 0.0.0.0:8099 0.0.0.0:* LISTEN 8286/haproxy
tcp 0 0 0.0.0.0:8099 0.0.0.0:* LISTEN 8205/haproxy
tcp6 0 0 :::22 :::* LISTEN 855/sshd
description: | updated |
description: | updated |
Changed in haproxy (Ubuntu): | |
assignee: | nobody → Louis Bouchard (louis-bouchard) |
Changed in haproxy (Ubuntu): | |
status: | New → In Progress |
importance: | Undecided → Medium |
affects: | haproxy (Ubuntu) → trusty-backports |
Changed in haproxy (Ubuntu): | |
importance: | Undecided → Medium |
Changed in haproxy (Ubuntu Trusty): | |
importance: | Undecided → Medium |
no longer affects: | haproxy (Ubuntu Trusty) |
Changed in trusty-backports: | |
assignee: | Louis Bouchard (louis-bouchard) → nobody |
tags: |
added: trusty removed: haproxy |
no longer affects: | haproxy (Ubuntu) |
summary: |
- HAProxy 1.5 init script does not terminate processes + Please backport haproxy 1.5.14-1ubuntu0.15.10.1 from wily-updates |
Hi,
haproxy 1.5.4 introduces the following change :
ret=0
- start-stop-daemon --quiet --oknodo --stop \
- --retry 5 --pidfile $PIDFILE --exec $HAPROXY || ret=$?
+ for pid in $(cat $PIDFILE); do
+ start-stop-daemon --quiet --oknodo --stop \
+ --retry 5 --pid $pid --exec $HAPROXY || ret=$?
+ done
start-stop-daemon --pidfile is replaced by --pid but this option is only available in dpkg 1.17.6 and onward :
$ man start-stop-daemon (on Wily) :
[--pid] pid
Check for a process with the specified pid (since version 1.17.6). The pid must be a number greater than 0.
This is not available on trusty, which explains why the process does not stop. I must admit that silently ignoring a false option is not an appropriate behavior though
The reason for that change is that, if nbproc > 1 in the haproxy config file, all the PIDs will be in one single /var/run/ haproxy. pid file so in order to kill each process, we must loop through the pid list.