Skip to content

Commit 7acf8a8

Browse files
committed
Make crash recovery ignore recovery target settings.
In v11 or before, recovery target settings could not take effect in crash recovery because they are specified in recovery.conf and crash recovery always starts without recovery.conf. But commit 2dedf4d integrated recovery.conf into postgresql.conf and which unexpectedly allowed recovery target settings to take effect even in crash recovery. This is definitely not good behavior. To fix the issue, this commit makes crash recovery always ignore recovery target settings. Back-patch to v12. Author: Peter Eisentraut Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/e445616d-023e-a268-8aa1-67b8b335340c@pgmasters.net
1 parent ac88807 commit 7acf8a8

File tree

1 file changed

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

1 file changed

+14
-0
lines changed

src/backend/access/transam/xlog.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5618,6 +5618,13 @@ recoveryStopsBefore(XLogReaderState *record)
56185618
TimestampTz recordXtime = 0;
56195619
TransactionId recordXid;
56205620

5621+
/*
5622+
* Ignore recovery target settings when not in archive recovery (meaning
5623+
* we are in crash recovery).
5624+
*/
5625+
if (!ArchiveRecoveryRequested)
5626+
return false;
5627+
56215628
/* Check if we should stop as soon as reaching consistency */
56225629
if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE && reachedConsistency)
56235630
{
@@ -5759,6 +5766,13 @@ recoveryStopsAfter(XLogReaderState *record)
57595766
uint8 rmid;
57605767
TimestampTz recordXtime;
57615768

5769+
/*
5770+
* Ignore recovery target settings when not in archive recovery (meaning
5771+
* we are in crash recovery).
5772+
*/
5773+
if (!ArchiveRecoveryRequested)
5774+
return false;
5775+
57625776
info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
57635777
rmid = XLogRecGetRmid(record);
57645778

0 commit comments

Comments
 (0)