Re: pg_ctl idempotent option

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Simon Riggs <simon(at)2ndQuadrant(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_ctl idempotent option
Date: 2013-01-29 22:03:08
Message-ID: 20130129220308.GA31285@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 29, 2013 at 04:34:50PM -0500, Peter Eisentraut wrote:
> On 1/28/13 9:29 PM, Bruce Momjian wrote:
> > pg_upgrade uses that to find out of the server was already running or if
> > we started it. This is to start the server to remove the
> > postmaster.pid file.
>
> It's currently a bit missed up anyway. pg_ctl start is successful if
> the server is already started, but pg_ctl -w start fails.

Yeah, that is odd:

# pg_ctl start
pg_ctl: another server might be running; trying to start server anyway
server starting
# FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 14144) running in data directory "/u/pgsql/data"?
# echo $?
0

# pg_ctl -w start
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start....FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 14144) running in data directory "/u/pgsql/data"?
....
pg_ctl: this data directory appears to be running a pre-existing postmaster
stopped waiting
pg_ctl: could not start server
Examine the log output.
# echo $?
1

It is because pg_ctl without -w doesn't want to see if the start was
successful. Fortunately, pg_upgrade always uses -w.

> What pg_upgrade is doing doesn't sound particularly safe, for example
> when something is concurrently starting or stopping the server.

Yes, there is always the risk of someone starting the server while it is
down during pg_upgrade; we assume the user has control of others
starting the server during pg_upgrade.

> > Also, no one has explained how not knowing if -o
> > options were used was a safe.
>
> Hmm, good point. But we already have this problem -- see above.

Yes, also true. I guess I can only stay it works for -w. :-(

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

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-01-29 22:23:39 Re: enhanced error fields
Previous Message Peter Eisentraut 2013-01-29 21:34:50 Re: pg_ctl idempotent option