mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-06 20:39:19 +02:00
Fix failure of archive recovery with recovery_min_apply_delay enabled.
recovery_min_apply_delay parameter is intended for use with streaming replication deployments. However, the document clearly explains that the parameter will be honored in all cases if it's specified. So it should take effect even if in archive recovery. But, previously, archive recovery with recovery_min_apply_delay enabled always failed, and caused assertion failure if --enable-caasert is enabled. The cause of this problem is that; the ownership of recoveryWakeupLatch that recovery_min_apply_delay uses was taken only when standby mode is requested. So unowned latch could be used in archive recovery, and which caused the failure. This commit changes recovery code so that the ownership of recoveryWakeupLatch is taken even in archive recovery. Which prevents archive recovery with recovery_min_apply_delay from failing. Back-patch to v9.4 where recovery_min_apply_delay was added. Author: Fujii Masao Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/CAHGQGwEyD6HdZLfdWc+95g=VQFPR4zQL4n+yHxQgGEGjaSVheQ@mail.gmail.com
This commit is contained in:
parent
03666dfa18
commit
9dfbf9a043
@ -6351,7 +6351,7 @@ StartupXLOG(void)
|
|||||||
* Take ownership of the wakeup latch if we're going to sleep during
|
* Take ownership of the wakeup latch if we're going to sleep during
|
||||||
* recovery.
|
* recovery.
|
||||||
*/
|
*/
|
||||||
if (StandbyModeRequested)
|
if (ArchiveRecoveryRequested)
|
||||||
OwnLatch(&XLogCtl->recoveryWakeupLatch);
|
OwnLatch(&XLogCtl->recoveryWakeupLatch);
|
||||||
|
|
||||||
/* Set up XLOG reader facility */
|
/* Set up XLOG reader facility */
|
||||||
@ -7334,7 +7334,7 @@ StartupXLOG(void)
|
|||||||
* We don't need the latch anymore. It's not strictly necessary to disown
|
* We don't need the latch anymore. It's not strictly necessary to disown
|
||||||
* it, but let's do it for the sake of tidiness.
|
* it, but let's do it for the sake of tidiness.
|
||||||
*/
|
*/
|
||||||
if (StandbyModeRequested)
|
if (ArchiveRecoveryRequested)
|
||||||
DisownLatch(&XLogCtl->recoveryWakeupLatch);
|
DisownLatch(&XLogCtl->recoveryWakeupLatch);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -11869,6 +11869,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
|
|||||||
* hope...
|
* hope...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We should be able to move to XLOG_FROM_STREAM
|
||||||
|
* only in standby mode.
|
||||||
|
*/
|
||||||
|
Assert(StandbyMode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Before we leave XLOG_FROM_STREAM state, make sure that
|
* Before we leave XLOG_FROM_STREAM state, make sure that
|
||||||
* walreceiver is not active, so that it won't overwrite
|
* walreceiver is not active, so that it won't overwrite
|
||||||
@ -11982,6 +11988,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
|
|||||||
{
|
{
|
||||||
bool havedata;
|
bool havedata;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We should be able to move to XLOG_FROM_STREAM
|
||||||
|
* only in standby mode.
|
||||||
|
*/
|
||||||
|
Assert(StandbyMode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if WAL receiver is still active.
|
* Check if WAL receiver is still active.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user