[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: Determine if postgresql cluster running is primary or not
From:       "David G. Johnston" <david.g.johnston () gmail ! com>
Date:       2020-11-20 17:53:34
Message-ID: CAKFQuwYSoCXb6rG-PDmYL6=0sKsfKJUciVYFzAOGXPhamWZjNw () mail ! gmail ! com
[Download RAW message or body]

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.

[Attachment #3 (text/html)]

On Friday, November 20, 2020, Paul Förster &lt;<a \
href="mailto:paul.foerster@gmail.com">paul.foerster@gmail.com</a>&gt; \
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex">Hi David,<br> <br>
&gt; On 20. Nov, 2020, at 10:34, David G. Johnston &lt;<a \
href="mailto:david.g.johnston@gmail.com">david.g.johnston@gmail.com</a>&gt; \
wrote:<br> &gt; <br>
&gt; <br>
&gt; On Friday, November 20, 2020, Paul Förster &lt;<a \
href="mailto:paul.foerster@gmail.com">paul.foerster@gmail.com</a>&gt; wrote:<br> &gt; \
<br> &gt; &gt; On 20. Nov, 2020, at 10:03, Thomas Kellerer &lt;<a \
href="mailto:shammat@gmx.net">shammat@gmx.net</a>&gt; wrote:<br> &gt; <br>
&gt; &gt; <br>
&gt; &gt;     select pg_is_in_recovery();<br>
&gt; <br>
&gt; I usually don&#39;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:<br> &gt; <br>
&gt; Do any of those other reasons allow connections that could execute that function \
to exist?<br> <br>
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.</blockquote><div><br></div><div>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).</div><div><br></div><div>David J.</div><div><br></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic