Commit 7acf8a87 authored by Fujii Masao's avatar Fujii Masao

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
2dedf4d9 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
parent ac88807f
...@@ -5618,6 +5618,13 @@ recoveryStopsBefore(XLogReaderState *record) ...@@ -5618,6 +5618,13 @@ recoveryStopsBefore(XLogReaderState *record)
TimestampTz recordXtime = 0; TimestampTz recordXtime = 0;
TransactionId recordXid; TransactionId recordXid;
/*
* Ignore recovery target settings when not in archive recovery (meaning
* we are in crash recovery).
*/
if (!ArchiveRecoveryRequested)
return false;
/* Check if we should stop as soon as reaching consistency */ /* Check if we should stop as soon as reaching consistency */
if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE && reachedConsistency) if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE && reachedConsistency)
{ {
...@@ -5759,6 +5766,13 @@ recoveryStopsAfter(XLogReaderState *record) ...@@ -5759,6 +5766,13 @@ recoveryStopsAfter(XLogReaderState *record)
uint8 rmid; uint8 rmid;
TimestampTz recordXtime; TimestampTz recordXtime;
/*
* Ignore recovery target settings when not in archive recovery (meaning
* we are in crash recovery).
*/
if (!ArchiveRecoveryRequested)
return false;
info = XLogRecGetInfo(record) & ~XLR_INFO_MASK; info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
rmid = XLogRecGetRmid(record); rmid = XLogRecGetRmid(record);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment