Skip to content

Commit c455ee8

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 47698b4 commit c455ee8

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
@@ -6386,7 +6386,7 @@ StartupXLOG(void)
63866386
* Take ownership of the wakeup latch if we're going to sleep during
63876387
* recovery.
63886388
*/
6389-
if (StandbyModeRequested)
6389+
if (ArchiveRecoveryRequested)
63906390
OwnLatch(&XLogCtl->recoveryWakeupLatch);
63916391

63926392
/* Set up XLOG reader facility */
@@ -7390,7 +7390,7 @@ StartupXLOG(void)
73907390
* We don't need the latch anymore. It's not strictly necessary to disown
73917391
* it, but let's do it for the sake of tidiness.
73927392
*/
7393-
if (StandbyModeRequested)
7393+
if (ArchiveRecoveryRequested)
73947394
DisownLatch(&XLogCtl->recoveryWakeupLatch);
73957395

73967396
/*
@@ -11924,6 +11924,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1192411924
* hope...
1192511925
*/
1192611926

11927+
/*
11928+
* We should be able to move to XLOG_FROM_STREAM
11929+
* only in standby mode.
11930+
*/
11931+
Assert(StandbyMode);
11932+
1192711933
/*
1192811934
* Before we leave XLOG_FROM_STREAM state, make sure that
1192911935
* walreceiver is not active, so that it won't overwrite
@@ -12035,6 +12041,12 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
1203512041
{
1203612042
bool havedata;
1203712043

12044+
/*
12045+
* We should be able to move to XLOG_FROM_STREAM
12046+
* only in standby mode.
12047+
*/
12048+
Assert(StandbyMode);
12049+
1203812050
/*
1203912051
* Check if WAL receiver is still active.
1204012052
*/

0 commit comments

Comments
 (0)