pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Förster <paul.foerster@gmail.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Thomas Kellerer <shammat@gmx.net>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Determine if postgresql cluster running is primary or not
Date: Fri, 20 Nov 2020 11:02:20 +0100
Message-ID: <7D1914CE-4A9C-4A3B-91D2-22954ACC2452@gmail.com> (raw)
In-Reply-To: <CAKFQuwbWCe+sQhR+Xg9Rz3Eh-0kTYD3x4+Tx9paAFntcNKeRLA@mail.gmail.com>
References: <CAO_+3-AV1WV_RfZ=7sbvNtwoZpvL23kpyzaUBJWRxhP47NVdOA@mail.gmail.com>
	<f09b2f94-d9a5-473c-d726-7e1aa53a7e94@gmx.net>
	<FD9D5838-D8AB-4466-A3DA-6780D09A429D@gmail.com>
	<CAKFQuwbWCe+sQhR+Xg9Rz3Eh-0kTYD3x4+Tx9paAFntcNKeRLA@mail.gmail.com>

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.

That was my idea when writing this query and it's been working fine for years now.

Cheers,
Paul




view thread (11+ messages)  latest in thread

Message-ID: <7D1914CE-4A9C-4A3B-91D2-22954ACC2452@gmail.com>
Permalink:  ../7D1914CE-4A9C-4A3B-91D2-22954ACC2452@gmail.com/
Also on:    postgresql.org/message-id/7D1914CE-4A9C-4A3B-91D2-22954ACC2452@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: paul.foerster@gmail.com, david.g.johnston@gmail.com, shammat@gmx.net
  Subject: Re: Determine if postgresql cluster running is primary or not
  In-Reply-To: <7D1914CE-4A9C-4A3B-91D2-22954ACC2452@gmail.com>
  References: <CAO_+3-AV1WV_RfZ=7sbvNtwoZpvL23kpyzaUBJWRxhP47NVdOA@mail.gmail.com> <f09b2f94-d9a5-473c-d726-7e1aa53a7e94@gmx.net> <FD9D5838-D8AB-4466-A3DA-6780D09A429D@gmail.com> <CAKFQuwbWCe+sQhR+Xg9Rz3Eh-0kTYD3x4+Tx9paAFntcNKeRLA@mail.gmail.com> <7D1914CE-4A9C-4A3B-91D2-22954ACC2452@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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