From: Tom Lane <tgl@sss.pgh.pa.us>
To: Greg k <gregg.kay@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Different behaviour for pg_ctl --wait between pg9.5 and pg10
Date: Mon, 19 Mar 2018 09:48:15 -0400
Message-ID: <20277.1521467295@sss.pgh.pa.us> (raw)
In-Reply-To: <CAC5zpv3KGkC=pqdgiCQ_aJEWGUUKV0GZpvMbMbC6KmY3imGmNg@mail.gmail.com>
References: <CAC5zpv3KGkC=pqdgiCQ_aJEWGUUKV0GZpvMbMbC6KmY3imGmNg@mail.gmail.com>
Greg k <gregg.kay@gmail.com> writes:
> I have a script where after a point-in-time recovery I run
> "pg_ctl start -D /data -w -t 86400"
> and then try to connect as soon as pg_ctl finishes. With Postgres 9.5.9 (on
> Centos 7.4) I can connect at the end. But with Postgres 10.3 I get a
> connection error
> psql: FATAL: the database system is starting up
> It seems with Postgres 10.3 the postmaster.pid file state goes from
> 'starting' to 'standby' to 'ready' but pg_ctl is saying the server is ready
> to accept connections even though the postmaster.pid file says 'standby'.
The problem from pg_ctl's standpoint is that it can't tell whether
"standby" is a short-lived state. In PG 10 it assumes not, so it exits
once that state is reached. The previous implementation couldn't
distinguish that state at all (because PQping doesn't) and would therefore
wait until the server accepted connections or it timed out. That happened
to be good for your use-case, I guess, but a lot of other people did not
like it: it led to waiting till timeout, and then reporting failure, when
starting a non-hot standby server. Even in the PITR case, there's no
certainty that the server will exit "standby" state in any prompt fashion
(ie, before pg_ctl times out), so that you did not really have a guarantee
before that the server would accept connections after pg_ctl exited.
I'd suggest adding a wait-for-psql-to-connect loop after your pg_ctl
start when starting a PITR run.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, gregg.kay@gmail.com
Subject: Re: Different behaviour for pg_ctl --wait between pg9.5 and pg10
In-Reply-To: <20277.1521467295@sss.pgh.pa.us>
References: <CAC5zpv3KGkC=pqdgiCQ_aJEWGUUKV0GZpvMbMbC6KmY3imGmNg@mail.gmail.com> <20277.1521467295@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox