Re: BUG #19002: `pg_isready` unexpectedly succeeds on incorrect `--dbname` and/or `--username`

From: Samuel Marks <samuelmarks(at)gmail(dot)com>
To: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19002: `pg_isready` unexpectedly succeeds on incorrect `--dbname` and/or `--username`
Date: 2025-07-30 03:01:16
Message-ID: CAMfPbcY+9YR6y+8qyn5SziO8--qBjGzBQO4A-PG=Q9zYmoyL1w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hmm I suppose that works, but really I was using it as a "can i connect"
check. Similar to https://github.com/eficode/wait-for or
https://github.com/wait4x/wait4x

It seems weird—unexpected to user—to accept dbname or user and not have a
non-zero exit code or something in stderr indicating failure…

Samuel Marks
Charity <https://sydneyscientific.org> | consultancy <https://offscale.io>
| open-source <https://github.com/offscale> | LinkedIn
<https://linkedin.com/in/samuelmarks>

On Tue, Jul 29, 2025 at 2:54 PM Jacob Champion <
jacob(dot)champion(at)enterprisedb(dot)com> wrote:

> On Tue, Jul 29, 2025 at 12:45 PM PG Bug reporting form
> <noreply(at)postgresql(dot)org> wrote:
> > / > pg_isready -U fff
> > /tmp:5432 - accepting connections
> > / > pg_isready -U fff -d555
> > /tmp:5432 - accepting connections
> > ```
> >
> > (`fff` is not a user and `555` is not a db on my installation)
>
> Hi Samuel, this behavior is explained in the docs [1]:
>
> > 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.
>
> So it's essentially just a courtesy to whoever's watching your logs.
>
> --Jacob
>
> [1]
> https://www.postgresql.org/docs/current/app-pg-isready.html#APP-PG-ISREADY-NOTES
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message shveta malik 2025-07-30 03:15:20 Re: Unexpected Standby Shutdown on sync_replication_slots change
Previous Message Jeff Davis 2025-07-29 23:33:45 CREATE DATABASE copies datlocale even if datlocprovider differs