On 2021/03/12 11:14, Hao Wu wrote:
Hi hackers, When we enable hot standby, HotStandbyActive() returns true on hot standby. Then, we promote the hot standby, the SHM variable `XLogCtl->SharedHotStandbyActive` remains true. So, HotStandbyActive() still returns true until the next call of `XLOGShmemInit()` even if the data node was promoted. `XLogWalRcvSendHSFeedback()` is the only caller of HotStandbyActive, it's probably not covered by the test cases. Is it the expected behavior or a bug in postgres? Probably a bug. I haven't much knowledge of hot-standby, a simple fix might be to set XLogCtl->SharedHotStandbyActive to false when the recovery process almost finishes. See the attachment.
So if walreceiver is only user of HotStandbyActive(), which means that there is no user of it after recovery finishes because walreceiver exits at the end of recovery? If this understanding is right, ISTM that HotStandbyActive() doesn't need to return false after recovery finishes because there is no user of it. No? Or you're implementing something that uses HotStandbyActive(), so want it to return false after the recovery? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION