From 53b48371693fed72fb9625f1af16786f92700e7b Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Mon, 2 Aug 2021 09:12:56 -0400
Subject: [PATCH] Further simplify a bit of logic in StartupXLOG().

Commit 7ff23c6d277d1d90478a51f0dd81414d343f3850 left us with two
identical cases. Collapse them.
---
 src/backend/access/transam/xlog.c | 34 +++++++++++++------------------
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index f84c0bb01e..8b39a2fdaa 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7890,28 +7890,22 @@ StartupXLOG(void)
 		 * after we're fully out of recovery mode and already accepting
 		 * queries.
 		 */
-		if (ArchiveRecoveryRequested && IsUnderPostmaster)
+		if (ArchiveRecoveryRequested && IsUnderPostmaster &&
+			LocalPromoteIsTriggered)
 		{
-			if (LocalPromoteIsTriggered)
-			{
-				promoted = true;
+			promoted = true;
 
-				/*
-				 * Insert a special WAL record to mark the end of recovery,
-				 * since we aren't doing a checkpoint. That means that the
-				 * checkpointer process may likely be in the middle of a
-				 * time-smoothed restartpoint and could continue to be for
-				 * minutes after this. That sounds strange, but the effect is
-				 * roughly the same and it would be stranger to try to come
-				 * out of the restartpoint and then checkpoint. We request a
-				 * checkpoint later anyway, just for safety.
-				 */
-				CreateEndOfRecoveryRecord();
-			}
-			else
-				RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY |
-								  CHECKPOINT_IMMEDIATE |
-								  CHECKPOINT_WAIT);
+			/*
+			 * Insert a special WAL record to mark the end of recovery, since
+			 * we aren't doing a checkpoint. That means that the checkpointer
+			 * process may likely be in the middle of a time-smoothed
+			 * restartpoint and could continue to be for minutes after this.
+			 * That sounds strange, but the effect is roughly the same and it
+			 * would be stranger to try to come out of the restartpoint and
+			 * then checkpoint. We request a checkpoint later anyway, just for
+			 * safety.
+			 */
+			CreateEndOfRecoveryRecord();
 		}
 		else
 		{
-- 
2.24.3 (Apple Git-128)

