Skip to content

Commit 9dfbf9a

Browse files
committed
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
1 parent 03666df commit 9dfbf9a

File tree

1 file changed

+14
-2
lines changed
  • src/backend/access/transam

1 file changed

+14
-2
lines changed

src/backend/access/transam/xlog.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6351,7 +6351,7 @@ StartupXLOG(void)
63516351
* Take ownership of the wakeup latch if we're going to sleep during
63526352
* recovery.
63536353
*/
6354-
if (StandbyModeRequested)
6354+
if (ArchiveRecoveryRequested)
63556355
OwnLatch(&XLogCtl->recoveryWakeupLatch);
63566356

63576357
/* Set up XLOG reader facility */
@@ -7334,7 +7334,7 @@ StartupXLOG(void)
73347334
* We don't need the latch anymore. It's not strictly necessary to disown
73357335
* it, but let's do it for the sake of tidiness.
73367336
*/
7337-
if (StandbyModeRequested)
7337+
if (ArchiveRecoveryRequested)
73387338
DisownLatch(&XLogCtl->recoveryWakeupLatch);
73397339

73407340
/*
@@ -11869,6 +11869,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1186911869
* hope...
1187011870
*/
1187111871

11872+
/*
11873+
* We should be able to move to XLOG_FROM_STREAM
11874+
* only in standby mode.
11875+
*/
11876+
Assert(StandbyMode);
11877+
1187211878
/*
1187311879
* Before we leave XLOG_FROM_STREAM state, make sure that
1187411880
* walreceiver is not active, so that it won't overwrite
@@ -11982,6 +11988,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1198211988
{
1198311989
bool havedata;
1198411990

11991+
/*
11992+
* We should be able to move to XLOG_FROM_STREAM
11993+
* only in standby mode.
11994+
*/
11995+
Assert(StandbyMode);
11996+
1198511997
/*
1198611998
* Check if WAL receiver is still active.
1198711999
*/

0 commit comments

Comments
 (0)