pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedpg_isready bug
3+ messages / 3 participants
[nested] [flat]
* pg_isready bug
@ 2020-04-13 12:53 Hunosau, Aliaksei <ahunosau@scnsoft.com>
2020-04-13 14:17 ` Re: pg_isready bug Fabien COELHO <coelho@cri.ensmp.fr>
0 siblings, 1 reply; 3+ messages in thread
From: Hunosau, Aliaksei @ 2020-04-13 12:53 UTC (permalink / raw)
To: pgsql-bugs
We are using Postgres in docker. And problem with pg_isready? was found.
Please, look:
root@29243fe45836:/# psql -U postgres
psql (11.6 (Debian 11.6-1.pgdg90+1))
Type "help" for help.
postgres=# \l+
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
-----------+----------+----------+------------+------------+-----------------------+---------+------------+--------------------------------------------
internal | postgres | UTF8 | en_US.utf8 | en_US.utf8 | | 12 MB | pg_default |
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 | | 7669 kB | pg_default | default administrative connection database
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +| 7529 kB | pg_default | unmodifiable empty database
| | | | | postgres=CTc/postgres | | |
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +| 7529 kB | pg_default | default template for new databases
| | | | | postgres=CTc/postgres | | |
(4 rows)
postgres=# exit
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
root@29243fe45836:/# pg_isready -d internal -h localhost -p 5432 -U postgres # the DB internal doesn't exist
localhost:5432 - accepting connections # looks good
root@29243fe45836:/# echo $?
0
The exitcodes of pg_isready if the DB doesn't exist and if exists are the same.
It will be better to exit with non null exitcode if pg_isready can't connect to absent db or using incorrect user.
Best regards,
[https://www.scnsoft.com/website/var/assets/logos/logo-64x64.png]<http://www.scnsoft.com/;
Aliaksei Hunosau, DevOps engineer
ScienceSoft - Professional Software Development
2 Bedy Street, Minsk, Belarus, 220040
P +375 17 293 37 36 | F+375 17 293 37 39
ahunosau@scnsoft.com<mailto:ahunosau@scnsoft.com>
www.scnsoft.com<https://www.scnsoft.com/?utm_source=EmailSignature&utm_medium=email&utm_campaign=GeneralEmai...; | LinkedIn<https://www.linkedin.com/company/sciencesoft?trk=srch_hero_comp_name; | Facebook<https://www.facebook.com/sciencesoft.solutions; | Twitter<https://twitter.com/ScienceSoft;
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_isready bug
2020-04-13 12:53 pg_isready bug Hunosau, Aliaksei <ahunosau@scnsoft.com>
@ 2020-04-13 14:17 ` Fabien COELHO <coelho@cri.ensmp.fr>
2020-04-14 00:33 ` Re: pg_isready bug Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 3+ messages in thread
From: Fabien COELHO @ 2020-04-13 14:17 UTC (permalink / raw)
To: Hunosau, Aliaksei <ahunosau@scnsoft.com>; +Cc: pgsql-bugs
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: pg_isready bug
2020-04-13 12:53 pg_isready bug Hunosau, Aliaksei <ahunosau@scnsoft.com>
2020-04-13 14:17 ` Re: pg_isready bug Fabien COELHO <coelho@cri.ensmp.fr>
@ 2020-04-14 00:33 ` Michael Paquier <michael@paquier.xyz>
0 siblings, 0 replies; 3+ messages in thread
From: Michael Paquier @ 2020-04-14 00:33 UTC (permalink / raw)
To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: Hunosau, Aliaksei <ahunosau@scnsoft.com>; pgsql-bugs
On Mon, Apr 13, 2020 at 04:17:21PM +0200, Fabien COELHO wrote:
> 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.
Yeah, that matches my impression when reading this thread. Perhaps
the docs had better emphasize that --timeout is a simple mapping for
the connection parameter connect_timeout in this case? My point is
that the logic tells us that the timeout is in effect when a
connection has been started, but not completed yet. And the docs of
pg_isready tell us that:
"The maximum number of seconds to wait when attempting connection
before returning that the server is not responding."
So this does not really insist on the point that a timeout has no
effect on a connection immediately failing because of an incorrect
parameter set.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-04-14 00:33 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 12:53 pg_isready bug Hunosau, Aliaksei <ahunosau@scnsoft.com>
2020-04-13 14:17 ` Fabien COELHO <coelho@cri.ensmp.fr>
2020-04-14 00:33 ` Michael Paquier <michael@paquier.xyz>
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