From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Hunosau, Aliaksei <ahunosau@scnsoft.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: pg_isready bug
Date: Mon, 13 Apr 2020 16:17:21 +0200 (CEST)
Message-ID: <alpine.DEB.2.21.2004131605150.27777@pseudo> (raw)
In-Reply-To: <1586782412339.75897@scnsoft.com>
References: <1586782412339.75897@scnsoft.com>
Hello,
> root@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@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.
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: coelho@cri.ensmp.fr, ahunosau@scnsoft.com
Subject: Re: pg_isready bug
In-Reply-To: <alpine.DEB.2.21.2004131605150.27777@pseudo>
* 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