Examining the log reveals that the error was caused by bind error:
address already used. This is strange because SO_REUSEADDR flags is
set to the listening socket. I guess the cause is, the kernel is not
fast enough to clean up the socket used by previous pgpool process.
To fix this, existing CHECK_TIME_WAIT environment variable parameter
is modified so that it checks the socket by using netstat -tulpn,
rather than netstat -a, which is too slow.
echo "PGPOOL_INSTALL_DIR=$PGPOOL_INSTALL_DIR" >> $SHUTDOWNALL
echo '$PGPOOL_INSTALL_DIR/bin/pgpool -f $dir/etc/pgpool.conf -m f stop && while [ -f $dir/run/pgpool.pid ];do sleep 1;done' >> $SHUTDOWNALL
if [ $CHECK_TIME_WAIT != "false" ];then
- echo "while netstat -a|grep $ORIGBASEPORT ;do sleep 1;done" >> $SHUTDOWNALL
+ echo "while netstat -tulpn 2>/dev/null|grep pgpool|grep -w $ORIGBASEPORT ;do sleep 1;done" >> $SHUTDOWNALL
fi
chmod 755 $SHUTDOWNALL
echo 'dir=`pwd`' > $PGPOOL_RELOAD
PSQLOPTS="-a -q -X"
PGPOOLBIN=$PGPOOL_INSTALL_DIR/bin
export PGDATABASE=test
+export CHECK_TIME_WAIT=true
# sleep time after reload in seconds
st=10