Re: Standby accepts recovery_target_timeline setting?

Peter Eisentraut <peter.eisentraut@2ndquadrant.com>

From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>, Fujii Masao <masao.fujii@gmail.com>
Cc: David Steele <david@pgmasters.net>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2019-09-28T21:07:59Z
Lists: pgsql-hackers
On 2019-09-28 19:45, Tom Lane wrote:
> Maybe I'm misunderstanding, but I think that rather than adding error
> checks that were not there before, the right path to fixing this is
> to cause these settings to be ignored if we're doing crash recovery.

That makes sense to me.  Something like this (untested)?

diff --git a/src/backend/access/transam/xlog.c
b/src/backend/access/transam/xlog.c
index 0daab3ff4b..25cae57131 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -5618,6 +5618,13 @@ recoveryStopsBefore(XLogReaderState *record)
 	TimestampTz recordXtime = 0;
 	TransactionId recordXid;

+	/*
+	 * Ignore recovery target settings when not in archive recovery (meaning
+	 * we are in crash recovery).
+	 */
+	if (!InArchiveRecovery)
+		return false;
+
 	/* Check if we should stop as soon as reaching consistency */
 	if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE && reachedConsistency)
 	{
@@ -5759,6 +5766,13 @@ recoveryStopsAfter(XLogReaderState *record)
 	uint8		rmid;
 	TimestampTz recordXtime;

+	/*
+	 * Ignore recovery target settings when not in archive recovery (meaning
+	 * we are in crash recovery).
+	 */
+	if (!InArchiveRecovery)
+		return false;
+
 	info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
 	rmid = XLogRecGetRmid(record);



-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



Commits

  1. Make crash recovery ignore recovery_min_apply_delay setting.

  2. Make crash recovery ignore restore_command and recovery_end_command settings.

  3. Make crash recovery ignore recovery target settings.

  4. doc: Further clarify how recovery target parameters are applied

  5. doc: Add timeline as valid recovery target in standby.signal documentation