Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 53443 - pg_autovacuum needs port argument to connect to postgresql server
Summary: pg_autovacuum needs port argument to connect to postgresql server
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: PgSQL Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-09 12:34 UTC by Paul Komarek
Modified: 2007-09-22 23:18 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Komarek 2004-06-09 12:34:51 UTC
The pg_autovacuum initscript and conf.d file (pg_autovacuum.init-7
.4.2,v 1.2 2004/05/25 15:57:26 nakano Exp ) do not support a port argument.  If your postgresql server uses a non-default port, pg_autovacuum will not find postgres and print errors.

This only applies when using TCP/IP with postgres (-i), at least as far as I know.

Reproducible: Always
Steps to Reproduce:
1.set your postgresql server to run on any port except 5432 (e.g. -p 1717)
2.run /etc/init.d/pg_autovacuum
3.

Actual Results:  
pg_autovacuum complains in the log file (default;
/var/lib/postgresql/data/pg_autovacuum.log):

[2004-06-09 01:03:03 PM] Failed connection to database template1 with error: cou
ld not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?



Expected Results:  
/etc/conf.d/pg_autovacuum should have a port variable, or some mechanism to send
generic args to the initscript.

I have created a very simple patch for the initscript and config file.  There
are included below:

------------------- initscript patch: /etc/init.d/pg_autovacuum ----------------
--- pg_autovacuum       2004-06-06 02:57:17.000000000 -0400
+++ pg_autovacuum.new   2004-06-09 13:17:42.362834616 -0400
@@ -8,8 +8,12 @@
 }
 
 start() {
+       # Check if port should be specified.
+       PGPORT_OPT=""
+       if [ -n "$PGPORT" ]; then PGPORT_OPT="-p $PGPORT"; fi
+
        ebegin "Starting pg_autovacuum"
-       start-stop-daemon --chuid $PGUSER --start --quiet --exec /usr/bin/pg_aut
ovacuum -- -D -v $VACUUM_BASE -V $VACUUM_SCALE -s $SLEEP_BASE -S $SLEEP_SCALE -L
 $PG_AUTOVACUUM_LOG
+       start-stop-daemon --chuid $PGUSER $PGPORT_OPT --start --quiet --exec /us
r/bin/pg_autovacuum -- -D -v $VACUUM_BASE -V $VACUUM_SCALE -s $SLEEP_BASE -S $SL
EEP_SCALE -L $PG_AUTOVACUUM_LOG
        sleep 1
        pidof /usr/bin/pg_autovacuum > /dev/null
        if [ $? -eq 0 ]; then
---------------------------------------------------------------------------


------------------- configuration patch: /etc/conf.d/pg_autovacuum ----------
--- pg_autovacuum       2004-06-06 02:57:17.000000000 -0400
+++ pg_autovacuum.new   2004-06-09 13:19:54.917713980 -0400
@@ -1,6 +1,9 @@
 # The PostgreSQL user is:
 PGUSER=postgres
 
+# If left unset, the default port will be used.
+# PGPORT=1717
+
 # LOG file is:
 PG_AUTOVACUUM_LOG=/var/lib/postgresql/data/pg_autovacuum.log
-----------------------------------------------------------------------------
Comment 1 Paul Komarek 2004-06-09 12:54:11 UTC
Doh!  I sent the wrong patch for the initscript.  Here is one that should actually work (unlike the previous, which is dead wrong -- the PGPORT_OPT variable is in the start-stop-daemon args instead of the pg_autovacuum args):

---------------------- initscript patch: /etc//init.d/pg_autovacuum ----------
--- pg_autovacuum       2004-06-06 02:57:17.000000000 -0400
+++ pg_autovacuum.new   2004-06-09 15:50:36.562436406 -0400
@@ -8,8 +8,13 @@
 }
 
 start() {
+       # Check if port should be specified.
+       PGPORT_OPT=""
+       if [ -n "$PGPORT" ]; then PGPORT_OPT="-p $PGPORT"; fi
+
        ebegin "Starting pg_autovacuum"
-       start-stop-daemon --chuid $PGUSER --start --quiet --exec /usr/bin/pg_autovacuum -- -D -v $VACUUM_BASE -V $VACUUM_SCALE -s $SLEEP_BASE -S $SLEEP_SCALE -L $PG_AUTOVACUUM_LOG
+       start-stop-daemon --chuid $PGUSER --start --quiet --exec /usr/bin/pg_autovacuum -- -D $PGPORT_OPT -v $VACUUM_BASE -V $VACUUM_SCALE -s $SLEEP_BASE -S $SLEEP_SCALE -L $PG_AUTOVACUUM_LOG
+       exit 10
        sleep 1
        pidof /usr/bin/pg_autovacuum > /dev/null
        if [ $? -eq 0 ]; then
------------------------------------------------------------------------
Comment 2 Tiziano Müller (RETIRED) gentoo-dev 2006-11-11 05:39:55 UTC
Finally fixed. Thanks for reporting.