Re: pg_ctl restart issue with relative paths

Lists: pgsql-bugs
From: Thom Brown <thom(at)linux(dot)com>
To: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: pg_ctl restart issue with relative paths
Date: 2012-10-13 22:56:43
Message-ID: CAA-aLv72O+NegjAipHORmbqSMZTkZayaTxrd+C9v60YbmMmZUQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Hi,

I have noticed that, using pg_ctl, if you start Postgres using a
relative path, then attempt to restart it from anywhere else, it
fails.

Example:

thom(at)swift /tmp $ pg_ctl -D primary start
server starting
thom(at)swift /tmp $ pg_ctl -D primary restart
waiting for server to shut down.... done
server stopped
server starting
thom(at)swift /tmp $ cd
thom(at)swift ~ $ pg_ctl -D /tmp/primary restart
waiting for server to shut down.... done
server stopped
server starting
thom(at)swift ~ $ postgres cannot access the server configuration file
"/home/thom/primary/postgresql.conf": No such file or directory

thom(at)swift ~ $ cd /tmp/primary
thom(at)swift /tmp/primary $ pg_ctl -D /tmp/primary restart
pg_ctl: PID file "/tmp/primary/postmaster.pid" does not exist
Is server running?
starting server anyway
server starting
thom(at)swift /tmp/primary $ postgres cannot access the server
configuration file "/tmp/primary/primary/postgresql.conf": No such
file or directory

thom(at)swift /tmp/primary $ cd ..
thom(at)swift /tmp $ pg_ctl -D /tmp/primary restart
pg_ctl: PID file "/tmp/primary/postmaster.pid" does not exist
Is server running?
starting server anyway
server starting

This issue does not occur if stopping then starting. I suspect the
blame lies with postmaster.opts not storing the resolved absolute
path.

OS: Linux Mint 13 64-bit
PostgreSQL version: 9.1.6 at least (just the stable version I tested
on), and git master

--
Thom


From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: Thom Brown <thom(at)linux(dot)com>
Cc: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: pg_ctl restart issue with relative paths
Date: 2012-10-14 16:56:46
Message-ID: CAK3UJRERVnNhcgof1s=ukOem00F5wnpZVzTxLbgWWJet3yTM2g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Sat, Oct 13, 2012 at 3:56 PM, Thom Brown <thom(at)linux(dot)com> wrote:

> I have noticed that, using pg_ctl, if you start Postgres using a
> relative path, then attempt to restart it from anywhere else, it
> fails.

Yeah, I was complaining about the same problem here:
http://archives.postgresql.org/pgsql-bugs/2011-10/msg00210.php

and at least there's a doc note now warning against using relative
paths, though it sure would be nice if we could fix this gripe.

Josh


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
Cc: Thom Brown <thom(at)linux(dot)com>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: pg_ctl restart issue with relative paths
Date: 2012-10-14 17:07:33
Message-ID: 27233.1350234453@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Josh Kupershmidt <schmiddy(at)gmail(dot)com> writes:
> On Sat, Oct 13, 2012 at 3:56 PM, Thom Brown <thom(at)linux(dot)com> wrote:
>> I have noticed that, using pg_ctl, if you start Postgres using a
>> relative path, then attempt to restart it from anywhere else, it
>> fails.

> Yeah, I was complaining about the same problem here:
> http://archives.postgresql.org/pgsql-bugs/2011-10/msg00210.php

I just re-read that thread, and it occurred to me that there is another
way to fix the problem: what we need is either for postmaster.opts to
not store the -D option at all, or for pg_ctl restart to override that
option with its freshly-derived idea of where the data directory is.
This would avoid my allergy to the idea of storing an absolute-ified
path, which I'm still down on because it would have failure modes of
its own.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
Cc: Thom Brown <thom(at)linux(dot)com>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: pg_ctl restart issue with relative paths
Date: 2012-10-15 19:27:48
Message-ID: 20121015192748.GF7494@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Sun, Oct 14, 2012 at 09:56:46AM -0700, Josh Kupershmidt wrote:
> On Sat, Oct 13, 2012 at 3:56 PM, Thom Brown <thom(at)linux(dot)com> wrote:
>
> > I have noticed that, using pg_ctl, if you start Postgres using a
> > relative path, then attempt to restart it from anywhere else, it
> > fails.
>
> Yeah, I was complaining about the same problem here:
> http://archives.postgresql.org/pgsql-bugs/2011-10/msg00210.php
>
> and at least there's a doc note now warning against using relative
> paths, though it sure would be nice if we could fix this gripe.

FYI, the doc patch is mentioned here:

http://archives.postgresql.org/pgsql-bugs/2012-08/msg00133.php

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +