pg_isready bug

From: "Hunosau, Aliaksei" <ahunosau(at)scnsoft(dot)com>
To: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: pg_isready bug
Date: 2020-04-13 12:53:32
Message-ID: 1586782412339.75897@scnsoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

We are using Postgres in docker. And problem with pg_isready? was found.

Please, look:

root(at)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(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
root(at)29243fe45836:/# pg_isready -d internal -h localhost -p 5432 -U postgres # the DB internal doesn't exist
localhost:5432 - accepting connections # looks good
root(at)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(at)scnsoft(dot)com<mailto:ahunosau(at)scnsoft(dot)com>
www.scnsoft.com<https://www.scnsoft.com/?utm_source=EmailSignature&utm_medium=email&utm_campaign=GeneralEmailSignature&utm_content=aliaksei.hunosau> | LinkedIn<https://www.linkedin.com/company/sciencesoft?trk=srch_hero_comp_name> | Facebook<https://www.facebook.com/sciencesoft.solutions> | Twitter<https://twitter.com/ScienceSoft>

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Fabien COELHO 2020-04-13 14:17:21 Re: pg_isready bug
Previous Message Tomas Vondra 2020-04-13 11:41:47 Re: backend crash