pg_ctl restart issue with relative paths

Started by Thom Brownover 13 years ago4 messagesbugs
Jump to latest
#1Thom Brown
thom@linux.com

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@swift /tmp $ pg_ctl -D primary start
server starting
thom@swift /tmp $ pg_ctl -D primary restart
waiting for server to shut down.... done
server stopped
server starting
thom@swift /tmp $ cd
thom@swift ~ $ pg_ctl -D /tmp/primary restart
waiting for server to shut down.... done
server stopped
server starting
thom@swift ~ $ postgres cannot access the server configuration file
"/home/thom/primary/postgresql.conf": No such file or directory

thom@swift ~ $ cd /tmp/primary
thom@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@swift /tmp/primary $ postgres cannot access the server
configuration file "/tmp/primary/primary/postgresql.conf": No such
file or directory

thom@swift /tmp/primary $ cd ..
thom@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

#2Josh Kupershmidt
schmiddy@gmail.com
In reply to: Thom Brown (#1)
Re: pg_ctl restart issue with relative paths

On Sat, Oct 13, 2012 at 3:56 PM, Thom Brown <thom@linux.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

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Josh Kupershmidt (#2)
Re: pg_ctl restart issue with relative paths

Josh Kupershmidt <schmiddy@gmail.com> writes:

On Sat, Oct 13, 2012 at 3:56 PM, Thom Brown <thom@linux.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

#4Bruce Momjian
bruce@momjian.us
In reply to: Josh Kupershmidt (#2)
Re: pg_ctl restart issue with relative paths

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@linux.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@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

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