Re: pg_isready bug

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: "Hunosau, Aliaksei" <ahunosau(at)scnsoft(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: pg_isready bug
Date: 2020-04-13 14:17:21
Message-ID: alpine.DEB.2.21.2004131605150.27777@pseudo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


Hello,

> root(at)29243fe45836:/# pg_isready -d 123456 -h localhost -p 5432 -U postgres # the DB 123456 doesn't exist
> localhost:5432 - accepting connections # but it shows all is good
> root(at)29243fe45836:/# echo $?
> 0

I can confirm, but I'm afraid it is a feature.

The server *is* indeed accepting connections… it does not say that the
connection with the parameters you supplied worked.

The feature relies on "PQpingParams" function which states the following
somehow strange sentence:

"It is not necessary to supply correct user name, password, or database
name values to obtain the server status; however, if incorrect values are
provided, the server will log a failed connection attempt."

The same occurs with a non existing user (-U).

Basically a connection is merely attempted, but it does not report success
of said connection. The sentence of "pg_isready --help" is somehow
ambiguous:

"pg_isready issues a connection check to a PostgreSQL database.", but no
one specified whaa a "connection check" is. I can understand that you
would expect to be an actual connection:-)

ISTM that the doc should be clarified about what is a "connection check",
and that it is not working a connection.

If you want to check that your parameters are ok, probably you want to
issue an actual psql run, eg:

psql <my param> -c "SELECT 'ok'"

--
Fabien.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-04-13 14:51:16 Re: [bug] Table not have typarray when created by single user mode
Previous Message Hunosau, Aliaksei 2020-04-13 12:53:32 pg_isready bug