Peter Eisentraut <peter_e@gmx.net> writes:
>> Really we'd need to change the postmaster too, because what we need to
>> do is send a query "are you ready to accept connections?" that the
>> postmaster will answer without an authentication exchange.
> ISTM that the rejection of a client with authentication failure is a
> pretty good indicator that you're accepting connections.
Well, no, it means that the postmaster is alive. It doesn't mean the
database is open for business yet --- the startup subprocess might still
be running.
I've just tweaked the postmaster so that startup/shutdown state is
checked immediately upon receiving the startup-request packet, and if
there's a database-state reason for rejecting the connection, that
will happen before going through the authentication protocol. This
should make it easier to write a pg_ping.
regards, tom lane