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

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: xrensis(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14356: "FATAL: the database system is starting up" error occurs to queries after PostgreSQL server start
Date: 2016-10-06 12:53:27
Message-ID: CAB7nPqTOHPBtf=hS6URN7=A2j_ma0GSzafA7mHGCJMvWvP_Duw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Oct 6, 2016 at 8:04 PM, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
> On 10/05/2016 05:25 PM, xrensis(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2016-10-06 14:15:59 Re: BUG #14243: pg_basebackup failes by a STATUS_DELETE_PENDING file
Previous Message Vitaly Burovoy 2016-10-06 12:50:55 Re: BUG #14354: Wrong interpretation of JSON 'null'