Re: Determine if postgresql cluster running is primary or not - Mailing list pgsql-general

From David G. Johnston
Subject Re: Determine if postgresql cluster running is primary or not
Date
Msg-id CAKFQuwYSoCXb6rG-PDmYL6=0sKsfKJUciVYFzAOGXPhamWZjNw@mail.gmail.com
Whole thread Raw
In response to Re: Determine if postgresql cluster running is primary or not  (Paul Förster <paul.foerster@gmail.com>)
List pgsql-general
On Friday, November 20, 2020, Paul Förster <paul.foerster@gmail.com> wrote:
Hi David,

> On 20. Nov, 2020, at 10:34, David G. Johnston <david.g.johnston@gmail.com> wrote:
>
>
> On Friday, November 20, 2020, Paul Förster <paul.foerster@gmail.com> wrote:
>
> > On 20. Nov, 2020, at 10:03, Thomas Kellerer <shammat@gmx.net> wrote:
>
> >
> >   select pg_is_in_recovery();
>
> I usually don't recommend using pg_is_in_recovery() only because a database cluster can be in recovery for other reasons. This is why I always do the following:
>
> Do any of those other reasons allow connections that could execute that function to exist?

that always depends on what your application does. An application could still select a lot of things, maybe even wrongly so, even if the cluster is in recovery mode.

I don’t follow - i posit that if psql successfully connects to a server that reports it is is recovery that server is a secondary to some other server, period.  Can you provide a counter-example for when that isn’t true (given the whole psql connects successfully bit).

David J.

pgsql-general by date:

Previous
From: "Zwettler Markus (OIZ)"
Date:
Subject: AW: Linux package upgrade without dependency conflicts
Next
From: Durumdara
Date:
Subject: pg_dump - how to force to show timestamps in client log