Re: BUG #14356: "FATAL: the database system is starting up" error occurs to queries after PostgreSQL server start - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: BUG #14356: "FATAL: the database system is starting up" error occurs to queries after PostgreSQL server start
Date
Msg-id CAB7nPqTOHPBtf=hS6URN7=A2j_ma0GSzafA7mHGCJMvWvP_Duw@mail.gmail.com
Whole thread Raw
In response to Re: BUG #14356: "FATAL: the database system is starting up" error occurs to queries after PostgreSQL server start  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-bugs
On Thu, Oct 6, 2016 at 8:04 PM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> On 10/05/2016 05:25 PM, xrensis@gmail.com wrote:
>>     - Is there a known interface to check if the database is up and fully
>> functional and ready for queries?
>
> The simplest way is to run a query with e.g. "psql -c 'select 1'", and see
> if it works.
>
> Note that you can also use "pg_ctl start -w" to have pg_ctl wait for the
> database to fully start up, before it returns.

That's one way. Have a look as well at pg_isready:
https://www.postgresql.org/docs/9.3/static/app-pg-isready.html
it is in 9.3, and is actually a wrapper of PQping(). Once it returns 0
as exit code, it means that the database is ready to accept incoming
connections.
--
Michael

pgsql-bugs by date:

Previous
From: Vitaly Burovoy
Date:
Subject: Re: BUG #14354: Wrong interpretation of JSON 'null'
Next
From: Kevin Grittner
Date:
Subject: Re: BUG #14243: pg_basebackup failes by a STATUS_DELETE_PENDING file