pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_isready docs doesn't specify what exactly it is checking
3+ messages / 3 participants
[nested] [flat]

* pg_isready docs doesn't specify what exactly it is checking
@ 2022-01-04 18:11 PG Doc comments form <noreply@postgresql.org>
  2022-01-07 00:29 ` Re: pg_isready docs doesn't specify what exactly it is checking Euler Taveira <euler@eulerto.com>
  0 siblings, 1 reply; 3+ messages in thread

From: PG Doc comments form @ 2022-01-04 18:11 UTC (permalink / raw)
  To: pgsql-docs@lists.postgresql.org; +Cc: anatoli@rainforce.org

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/app-pg-isready.html
Description:

`pg_isready` docs don't specify how its different from a port probe - what
does on top of checking that a port is open? Does it send some handshake
message that a server responds to when initialization is finished?

People here are telling that `pg_isready` is not reliable and that
`pg_isready` may return when database is not actually ready
https://github.com/docker-library/postgres/issues/880#issuecomment-1004251102
Without further info about `pg_isready` it is not clear if it should be
filled as a bug. Or if it should be filled as a bug only when an
initialization script is involved.


^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_isready docs doesn't specify what exactly it is checking
  2022-01-04 18:11 pg_isready docs doesn't specify what exactly it is checking PG Doc comments form <noreply@postgresql.org>
@ 2022-01-07 00:29 ` Euler Taveira <euler@eulerto.com>
  2022-01-07 00:50   ` Re: pg_isready docs doesn't specify what exactly it is checking Anatoli Babenia <anatoli@rainforce.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Euler Taveira @ 2022-01-07 00:29 UTC (permalink / raw)
  To: anatoli@rainforce.org; pgsql-docs@lists.postgresql.org

On Tue, Jan 4, 2022, at 3:11 PM, PG Doc comments form wrote:
> `pg_isready` docs don't specify how its different from a port probe - what
> does on top of checking that a port is open? Does it send some handshake
> message that a server responds to when initialization is finished?
pg_isready uses a PQping function that reports the current Postgres status. The
main advantage of pg_isready is that it uses the Postgres protocol to report
the server status. A port probe is not a sufficient step to determine if the
server is running and accepting connections. Why? A Postgres server can be
running but in a state that disallows connections such as during a startup or
crash recovery phase. pg_isready is capable of reporting such state
(PQPING_REJECT -- 1) [1].

We could include a sentence explaining that a port probe is not a sufficient
condition to successfully connect to a Postgres server because the state
machine has more than 2 states. PQping [1] already states "reports the status
of the server" and describe each state it provides. Feel free to suggest an
improvement to documentation.

> People here are telling that `pg_isready` is not reliable and that
> `pg_isready` may return when database is not actually ready
> https://github.com/docker-library/postgres/issues/880#issuecomment-1004251102
> Without further info about `pg_isready` it is not clear if it should be
> filled as a bug. Or if it should be filled as a bug only when an
> initialization script is involved.
There is no known issues with pg_isready and that report isn't clear. He says
"database and/or user wasn't available". What's the exact error message? If
there is a reproducible test case, share it here.


[1] https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PQPINGPARAMS


--
Euler Taveira
EDB   https://www.enterprisedb.com/

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_isready docs doesn't specify what exactly it is checking
  2022-01-04 18:11 pg_isready docs doesn't specify what exactly it is checking PG Doc comments form <noreply@postgresql.org>
  2022-01-07 00:29 ` Re: pg_isready docs doesn't specify what exactly it is checking Euler Taveira <euler@eulerto.com>
@ 2022-01-07 00:50   ` Anatoli Babenia <anatoli@rainforce.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Anatoli Babenia @ 2022-01-07 00:50 UTC (permalink / raw)
  To: Euler Taveira <euler@eulerto.com>; +Cc: pgsql-docs@lists.postgresql.org

On Fri, 7 Jan 2022 at 03:29, Euler Taveira <euler@eulerto.com> wrote:

> On Tue, Jan 4, 2022, at 3:11 PM, PG Doc comments form wrote:
>
> We could include a sentence explaining that a port probe is not a
> sufficient
> condition to successfully connect to a Postgres server because the state
> machine has more than 2 states. PQping [1] already states "reports the
> status
> of the server" and describe each state it provides. Feel free to suggest an
> improvement to documentation.
>

A diagram of the state machine would be very useful.

There is no known issues with pg_isready and that report isn't clear. He
> says
> "database and/or user wasn't available". What's the exact error message? If
> there is a reproducible test case, share it here.
>

PostgreSQL docker image can run initialization scripts at container start to
create database, users and maybe load some data. So when pg_isready
reports success, the DB can still be in an inconsistent state for an app to
start
using it.
-- 
Anatoli Babenia

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-01-07 00:50 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-01-04 18:11 pg_isready docs doesn't specify what exactly it is checking PG Doc comments form <noreply@postgresql.org>
2022-01-07 00:29 ` Euler Taveira <euler@eulerto.com>
2022-01-07 00:50   ` Anatoli Babenia <anatoli@rainforce.org>

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