Re: pg_ctl idempotent option

Bruce Momjian <bruce@momjian.us>

From: Bruce Momjian <bruce@momjian.us>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: Simon Riggs <simon@2ndQuadrant.com>, Alvaro Herrera <alvherre@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers@postgresql.org
Date: 2013-01-29T22:03:08Z
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@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

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