Package: pgbouncer Version: 1.3-1 Severity: important Fernando,
"/etc/init.d/pgbouncer stop" fails to stop pgbouncer if clients are connected. You can easily reproduce this bug with the following procedure: - configure and start postgresql - configure and start pgbouncer - connect to pgbouncer and make a query in order for pgbouncer to be connected to postgresql : # psql -p 5433 -h localhost -U postgres Welcome to psql 8.3.6 (server 8.3.7), the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit postgres=# SELECT 1; ?column? ---------- 1 (1 row) postgres=# - keep the psql client open - try to stop pgbouncer: # /etc/init.d/pgbouncer stop Stopping: pgbouncer. - pgbouncer is still running: # ps -C pgbouncer h 4342 ? S< 0:04 /usr/sbin/pgbouncer -d /etc/pgbouncer/pgbouncer.ini - because the client is still connected: # ps -C postgres h | grep local 5934 ? S<s 0:00 postgres: postgres postgres [local] idle - stop the client: postgres=# \q # - now pgbouncer has stopped: # ps -C pgbouncer h # When trying to "/etc/init.d/pgbouncer restart" when many clients are connected, it's even worst: it looks like the daemon has been successfully restarted without any error but it's just waiting for clients to disconnect. pgbouncer will eventually stop few minutes/hours/days/weeks after, when all clients have decided to disconnect at the same time and it looks like a crash. I've made a patch to fix this issue. It sends different signals to the daemon until it terminates properly, SIGINT then SIGTERM then SIGKILL with a 1 second delay between each. I hope it helps, -- System Information: Debian Release: squeeze/sid APT prefers oldstable APT policy: (500, 'oldstable'), (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 2.6.26-1-amd64 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to en_US.UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages pgbouncer depends on: ii libc6 2.9-5 GNU C Library: Shared libraries ii libevent1 1.3e-3 An asynchronous event notification ii lsb-base 3.2-20 Linux Standard Base 3.2 init scrip ii postgresql-common 97 PostgreSQL database-cluster manage pgbouncer recommends no packages. pgbouncer suggests no packages. -- no debconf information -- ,''`. : :' : Cyril Bouthors `. `' Debian.org `-
*** pgbouncer.00 Sun Mar 1 02:51:17 2009 --- pgbouncer Wed Apr 8 07:51:34 2009 *************** *** 43,56 **** fi } ! d_stop() { ! SIG=${1:-INT} ! killproc -p $PIDFILE $DAEMON $SIG ! status=$? ! [ $status -eq 0 ] || [ $status -eq 3 ] ! return $? } case "$1" in start) --- 43,65 ---- fi } ! d_reload() { ! is_running || return 0 ! ! killproc -p $PIDFILE $DAEMON HUP } + d_stop() { + SIGS='INT TERM KILL' + + for sig in $SIGS + do + is_running || return 0 + + killproc -p $PIDFILE $DAEMON $sig + sleep 1 + done + } case "$1" in start) *************** *** 79,85 **** ;; restart|force-reload) log_daemon_msg "Restarting pgbouncer" pgbouncer ! d_stop && sleep 1 && d_start log_end_msg $? ;; try-restart) --- 88,95 ---- ;; restart|force-reload) log_daemon_msg "Restarting pgbouncer" pgbouncer ! d_stop ! d_start log_end_msg $? ;; try-restart) *************** *** 92,98 **** reload) if is_running; then log_daemon_msg "Reloading configuration" pgbouncer ! d_stop -HUP log_end_msg $? else log_failure_msg "pgbouncer is not running." --- 102,108 ---- reload) if is_running; then log_daemon_msg "Reloading configuration" pgbouncer ! d_reload log_end_msg $? else log_failure_msg "pgbouncer is not running."