pg_ctl -w vs unix_socket_directory

Lists: pgsql-hackers
From: Radoslaw Zielinski <radek42(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: pg_ctl -w vs unix_socket_directory
Date: 2007-09-18 22:24:54
Message-ID: 20070918222454.GA14278@bzium
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

"pg_ctl -w -D ... start" doesn't work when unix_socket_directory is set
to somewhere else than the compiled in default ("/tmp"). Having this is
useful for the startup scripts, so the status "DONE" actually means
success, instead of "maybe".

Jeff Davis wrote about it a while ago:
http://svr5.postgresql.org/pgsql-general/2006-09/msg01141.php

Simple hacky patch for v8.2.5; maybe someone finds it useful before
the proper config parser is integrated:
http://cvs.pld-linux.org/cgi-bin/cvsweb/SOURCES/postgresql-pg_ctl-fix.patch?rev=HEAD

--
Radosław Zieliński <radek(at)pld-linux(dot)org>


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Radoslaw Zielinski <radek42(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_ctl -w vs unix_socket_directory
Date: 2007-09-18 22:42:14
Message-ID: 46F05446.5030203@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


This has a trivial workaround - just set PGHOST for pg_ctl:

[andrew(at)constanza inst.codfix.5705]$
PGHOST=/home/andrew/pgl/inst.codfix.5705 bin/pg_ctl -D data/ -l logfile
-w start
waiting for server to start.... done
server started
[andrew(at)constanza inst.codfix.5705]$

cheers

andrew

Radoslaw Zielinski wrote:
> Hello,
>
> "pg_ctl -w -D ... start" doesn't work when unix_socket_directory is set
> to somewhere else than the compiled in default ("/tmp"). Having this is
> useful for the startup scripts, so the status "DONE" actually means
> success, instead of "maybe".
>
> Jeff Davis wrote about it a while ago:
> http://svr5.postgresql.org/pgsql-general/2006-09/msg01141.php
>
>
> Simple hacky patch for v8.2.5; maybe someone finds it useful before
> the proper config parser is integrated:
> http://cvs.pld-linux.org/cgi-bin/cvsweb/SOURCES/postgresql-pg_ctl-fix.patch?rev=HEAD
>
>


From: Radoslaw Zielinski <radek42(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_ctl -w vs unix_socket_directory
Date: 2007-09-18 23:00:14
Message-ID: 20070918230014.GA14511@bzium
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> [18-09-2007 23:42]:
> This has a trivial workaround - just set PGHOST for pg_ctl:

> [andrew(at)constanza inst.codfix.5705]$
> PGHOST=/home/andrew/pgl/inst.codfix.5705 bin/pg_ctl -D data/ -l logfile -w
> start

That would be fine for a particular installation, but isn't really
suitable for a startup script shipped with a linux distribution. Sure,
a /bin/sh-based postgresql.conf parser could do the trick... but I just
don't feel like writing one. :-)

--
Radosław Zieliński <radek(at)pld-linux(dot)org>


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Radoslaw Zielinski <radek42(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_ctl -w vs unix_socket_directory
Date: 2007-09-18 23:13:51
Message-ID: 11786.1190157231@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Radoslaw Zielinski <radek42(at)gmail(dot)com> writes:
> "pg_ctl -w -D ... start" doesn't work when unix_socket_directory is set
> to somewhere else than the compiled in default ("/tmp").

pg_ctl not working is going to be the very least of your worries;
pretty much nothing else will either.

If you want some other socket directory, I strongly recommend setting
the path to it at compile time so that it's properly wired into libpq.
AFAICS the only value in specifying unix_socket_directory at server
start is if you actually *want* a stealth server that won't be found
by clients without manual intervention.

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_ctl -w vs unix_socket_directory
Date: 2007-09-18 23:23:52
Message-ID: 46F05E08.5080701@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Radoslaw Zielinski wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> [18-09-2007 23:42]:
>
>> This has a trivial workaround - just set PGHOST for pg_ctl:
>>
>
>
>> [andrew(at)constanza inst.codfix.5705]$
>> PGHOST=/home/andrew/pgl/inst.codfix.5705 bin/pg_ctl -D data/ -l logfile -w
>> start
>>
>
> That would be fine for a particular installation, but isn't really
> suitable for a startup script shipped with a linux distribution. Sure,
> a /bin/sh-based postgresql.conf parser could do the trick... but I just
> don't feel like writing one. :-)
>
>

I think it's broken for a distro to ship with config files setting a
socket dir other than the one they compile in.

If you don't like /tmp compile in something else. The you don't need to
parse anything.

cheers

andrew


From: Radosław Zieliński <radek42(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_ctl -w vs unix_socket_directory
Date: 2007-09-19 10:04:01
Message-ID: a8dae1ea0709190304iac662dfsc4a73170cd0bba23@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 19/09/2007, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
> Radoslaw Zielinski wrote:
[...]
> > That would be fine for a particular installation, but isn't really
> > suitable for a startup script shipped with a linux distribution. Sure,
[...]
> I think it's broken for a distro to ship with config files setting a
> socket dir other than the one they compile in.

The distro uses the default, of course. The issue is: the startup
script stops working if a sysadmin changes it manually, for whatever
reason.


From: Radosław Zieliński <radek42(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_ctl -w vs unix_socket_directory
Date: 2007-09-19 10:07:29
Message-ID: a8dae1ea0709190307r7fa72140t69d9001ce77f8079@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 19/09/2007, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Radoslaw Zielinski <radek42(at)gmail(dot)com> writes:
> > "pg_ctl -w -D ... start" doesn't work when unix_socket_directory is set
> > to somewhere else than the compiled in default ("/tmp").
> pg_ctl not working is going to be the very least of your worries;
> pretty much nothing else will either.

> If you want some other socket directory, I strongly recommend setting
[...]

I don't want any other socket directory. All I want is a way to
create a working startup script: able to start/stop the server
regardless of changes in postgresql.conf and report the success or
failure.


From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Radoslaw Zielinski <radek42(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_ctl -w vs unix_socket_directory
Date: 2007-09-19 19:04:58
Message-ID: 1190228698.5943.57.camel@dogma.ljc.laika.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 2007-09-18 at 19:13 -0400, Tom Lane wrote:
> Radoslaw Zielinski <radek42(at)gmail(dot)com> writes:
> > "pg_ctl -w -D ... start" doesn't work when unix_socket_directory is set
> > to somewhere else than the compiled in default ("/tmp").
>
> pg_ctl not working is going to be the very least of your worries;
> pretty much nothing else will either.
>

If you mean client applications won't work, that would be expected from
such a change to the server configuration.

> If you want some other socket directory, I strongly recommend setting
> the path to it at compile time so that it's properly wired into libpq.
> AFAICS the only value in specifying unix_socket_directory at server
> start is if you actually *want* a stealth server that won't be found
> by clients without manual intervention.
>

Those arguments apply almost as well to the server port. The server port
is read from the postgresql.conf from pg_ctl, but not the socket
directory.

It's an annoyance: if you change the default socket directory, you're
probably going to break your init script (on FreeBSD you will, because
it uses "-w"). I don't think that's the expected result, and it's not
intuitive to find the cause of the problem.

I think the inconsistency between server port number and socket
directory is less than ideal. However, I also don't feel very strongly
about it. It's rare, and a there are plenty of workarounds.

Regards,
Jeff Davis