Re: [HACKERS] [PATCH v1] Add and report the new "in_hot_standby" GUC pseudo-variable. - Mailing list pgsql-hackers

From Elvis Pranskevichus
Subject Re: [HACKERS] [PATCH v1] Add and report the new "in_hot_standby" GUC pseudo-variable.
Date
Msg-id 1610850.8GvGs1Lbrr@hammer.magicstack.net
Whole thread Raw
In response to Re: [HACKERS] [PATCH v1] Add and report the new "in_hot_standby" GUC pseudo-variable.  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: [HACKERS] [PATCH v1] Add and report the new "in_hot_standby" GUC pseudo-variable.  (Jaime Casanova <jaime.casanova@2ndquadrant.com>)
List pgsql-hackers
On Saturday, March 18, 2017 3:33:16 AM EDT Michael Paquier wrote:
> On Sat, Mar 18, 2017 at 2:56 AM, Elvis Pranskevichus 
<elprans@gmail.com> wrote:
> > Currently, clients wishing to know when the server exits hot standby
> > have to resort to polling, which is often suboptimal.
> > 
> > This adds the new "in_hot_standby" GUC variable that is reported via
> > a> 
> > ParameterStatus message.  This allows the clients to:
> >    (a) know right away that they are connected to a server in hot
> >    
> >        standby; and
> >    
> >    (b) know immediately when a server exits hot standby.
> > 
> > This change will be most beneficial to various connection pooling
> > systems (pgpool etc.)
> 
> Why adding a good chunk of code instead of using pg_is_in_recovery(),
> which switches to false once a server exits recovery?

That requires polling the database continuously, which may not be 
possible or desirable.  

My main motivation here is to gain the ability to manage a pool of 
connections in asyncpg efficiently.  A part of the connection release 
protocol is "UNLISTEN *;", which the server in Hot Standby would fail to 
process.  Polling the database for pg_is_in_recovery() is not feasible 
in this case, unfortunately.
                            Elvis  



pgsql-hackers by date:

Previous
From: Petr Jelinek
Date:
Subject: Re: [HACKERS] PoC plpgsql - possibility to force custom or genericplan
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] [PATCH] Use $ parameters as replacement characters for pg_stat_statements