Re: HotStandbyActive() issue in postgres

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Hao Wu <hawu(at)vmware(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Paul Guo <guopa(at)vmware(dot)com>
Subject: Re: HotStandbyActive() issue in postgres
Date: 2021-03-16 08:44:55
Message-ID: 055be3fb-bf31-e080-1e58-8e8faf38fa57@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021/03/16 12:24, Hao Wu wrote:
> Yes, I have an extension/UDF that needs to know if the server is currently
> running as hot standby. For example, a UDF foo() wants to run on
> both the primary and secondary and runs different behaviors for different
> roles.
> Promoted secondary looks the same as the primary since it's no longer
> real hot standby. Does it make sense?

If UDF, using RecoveryInProgress() is enough? If RecoveryInProgress() returns
false, UDF can determine that the server is working as a primary. If true is
returned, UDF can determine that the server is working as a secondary and
hot standby is active because you can connect to the server and UDF can be
called. If hot standby is not active during recovery, you cannot conect to
the server and cannot run UDF, so UDF doesn't need to handle the case where
hot standby is not active during recovery. Thought?

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2021-03-16 08:59:39 Re: Allow batched insert during cross-partition updates
Previous Message Fujii Masao 2021-03-16 08:29:05 Re: fdatasync performance problem with large number of DB files