Skip site navigation (1) Skip section navigation (2)

Fwd: Bug#358546: failure of pg_ctl start -w -D

From: Martin Pitt <mpitt(at)debian(dot)org>
To: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Fwd: Bug#358546: failure of pg_ctl start -w -D
Date: 2006-03-26 12:37:21
Message-ID: (view raw or whole thread)
Lists: pgsql-bugs
Hi PostgreSQL developers,

the bug report below was recently sent to Debian. The details and my
reply are at, the executive summary is:
pg_ctl's -w option does not honour postgresql.conf's
unix_socket_directory configuration (and neither $PGHOST).



----- Forwarded message from Stephen Gildea <gildea(at)stop(dot)mail-abuse(dot)org> -----

Subject: Bug#358546: failure of pg_ctl start -w -D
Reply-To: Stephen Gildea <gildea(at)stop(dot)mail-abuse(dot)org>,
From: Stephen Gildea <gildea(at)stop(dot)mail-abuse(dot)org>
To: submit(at)bugs(dot)debian(dot)org
Date: Wed, 22 Mar 2006 22:39:27 -0500
X-Spam-Status: No, score=1.3 required=4.0 tests=BAYES_50,DATE_IN_FUTURE_06_12 
	autolearn=no version=3.0.3

Package: postgresql-7.4
Version: 7.4.12-2
Tags: patch

When starting the PostgreSQL server (with "pg_ctl start") with a
specific directory (the -D flag), the "wait" code (triggered with the -w
option) fails to use the directory to find the Unix socket, and so it
fails to connect to the newly-started server.

To repeat, create a new database and start a server on it:

/usr/lib/postgresql/bin/initdb -D /some/directory
Edit /some/directory/postgresql.conf to define unix_socket_directory.
 (It may be a separate bug that this step is necessary.)
/usr/lib/postgresql/bin/pg_ctl start -w -D /some/directory -l /some/directory/postgres.log
Note the "failed" error message, even though the server did start.

The following simple patch passes the Unix socket directory to psql for
the wait check.

In PostgreSQL 8, the pg_ctl shell script has been replaced by a C
program.  I haven't tested it, but from looking at the code in pg_ctl.c,
I suspect the same bug is present.  Running "start -w" calls
test_postmaster_connection().  As with the buggy script, that routine
sets only the port and fails to set the host/directory as well.

 < Stephen

--- postgresql-7.4.12/src/bin/pg_ctl/	2004-10-21 20:24:27.000000000 -0400
+++ src/bin/pg_ctl/	2006-03-20 13:31:23.000000000 -0500
@@ -387,20 +387,23 @@
     if [ -z "$PGPORT" ];then
         PGPORT=`sed -ne 's/^[ 	]*port[^=]*=[ 	]\+\([0-9]\+\).*/\1/p' $CONFFILE 2>/dev/null`
         if [ -z "$PGPORT" ];then
+    if [ -z "$PGHOST" ];then
+        PGHOST=`sed -ne "s/^[ 	]*unix_socket_directory[^=]*=[ 	]\+'\([^'].*\)'/\1/p" "$CONFFILE" 2>/dev/null`
+    fi
     # wait for postmaster to start
     if [ "$wait" = yes ];then
 	$silence_echo $ECHO_N "waiting for postmaster to start..."$ECHO_C
 	while :
-	    if "$PGPATH/psql" -p $PGPORT -l >/dev/null 2>&1
+	    if "$PGPATH/psql" -p $PGPORT -h "$PGHOST" -l >/dev/null 2>&1
 		$silence_echo $ECHO_N "."$ECHO_C
 		cnt=`expr $cnt + 1`
 		if [ "$cnt" -gt "$wait_seconds" ];then

----- End forwarded message -----

Martin Pitt
Ubuntu Developer
Debian Developer

In a world without walls and fences, who needs Windows and Gates?

pgsql-bugs by date

Next:From: Martin PittDate: 2006-03-26 12:49:43
Subject: Fwd: Bug#358546: failure of pg_ctl start -w -D
Previous:From: Alexis WilkeDate: 2006-03-26 00:01:09
Subject: BUG #2358: Vacuum & \dt problems

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group