Re: Bug with pg_ctl -w/wait and config-only directories

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: "Mr(dot) Aaron W(dot) Swenson" <titanofold(at)gentoo(dot)org>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug with pg_ctl -w/wait and config-only directories
Date: 2011-10-05 23:20:16
Message-ID: 201110052320.p95NKG018205@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Mr. Aaron W. Swenson wrote:
-- Start of PGP signed section.
> On Wed, Oct 05, 2011 at 10:44:38AM -0400, Bruce Momjian wrote:
> > Peter Eisentraut wrote:
> > > On m?n, 2011-10-03 at 15:09 -0400, Bruce Momjian wrote:
> > > > Why were people not using pg_ctl?
> > >
> > > Actually, a slight correction/addition here: The Debian init script does
> > > use pg_ctl to start the service. Seems to work fine.
> >
> > Yes. The script authors discovered a working behavior, which matches my
> > research:
> >
> > pg_ctl start specify config directory
> > pg_ctl -w start impossible
> > ...
>
>
> Maybe I'm misunderstanding what you've written, but for 'pg_ctl -w' it is
> possible. The following command does work (I've replaced the variables
> with their default values to make it easier to read):
>
> su -l postgres \
> -c "env PGPORT=\"5432\" /usr/lib/postgresql-9.1/bin/pg_ctl start -w \
> -t 60 -s -D /var/lib/postgresql/9.1/data/ \
> -o '-D /etc/postgresql-9.1/ \
> --data-directory=/var/lib/postgresql/9.1/data/ \
> --silent-mode=true'"

Wow. So you are telling pg_ctl to use the real data directory, but are
passing flags to the postmaster to start with the config directory and
also setting data-directory to the real data directory. I am impressed.

I can see how that would work. Did you look at the C code to figure
this out or did you just test until it worked, or did it just seem
logical to you?

With the patch I am going to commit, you will not need to use one of the
-D flags because pg_ctl will find the data directory location; you will
just specify the config-only directory with one -D, and the
--data-directory.

pg_upgrade could use this method if it had -o options for old and new
clusters. Right now it has -p and -P and those could be removed and use
-o/-O instead, but it would require parsing the -o string, with is
problematic. The right solution for the port number would be to use the
new postmaster -C option, pass the -o into that, and read the port
number with 'postmaster -C port'.

--
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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mr. Aaron W. Swenson 2011-10-05 23:53:05 Re: Bug with pg_ctl -w/wait and config-only directories
Previous Message Marti Raudsepp 2011-10-05 22:59:55 Re: [PATCH] Log crashed backend's query v2