From 31f00d163b44be096b8282880528fc199f3cc98e Mon Sep 17 00:00:00 2001
From: Simon Riggs <simon@2ndQuadrant.com>
Date: Fri, 2 Apr 2010 13:10:56 +0000
Subject: [PATCH] Move system startup message prior to any calls out of data
 directory. This allows us to see what mode the server is in before it starts
 to perform actions that can block or hang. Otherwise server messages may not
 appear until after messages that say FATAL the database server is starting
 up.

---
 src/backend/access/transam/xlog.c | 36 ++++++++++++++++---------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index dfe2593c996..247ba3d8e78 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.386 2010/04/01 00:43:29 rhaas Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.387 2010/04/02 13:10:56 sriggs Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -5557,6 +5557,24 @@ StartupXLOG(void)
 			restartPointCommand ? restartPointCommand : "",
 			sizeof(XLogCtl->restartPointCommand));
 
+	if (InArchiveRecovery)
+	{
+		if (StandbyMode)
+			ereport(LOG,
+					(errmsg("entering standby mode")));
+		else if (recoveryTarget == RECOVERY_TARGET_XID)
+			ereport(LOG,
+					 (errmsg("starting point-in-time recovery to XID %u",
+						 recoveryTargetXid)));
+		else if (recoveryTarget == RECOVERY_TARGET_TIME)
+			ereport(LOG,
+					(errmsg("starting point-in-time recovery to %s",
+							timestamptz_to_str(recoveryTargetTime))));
+		else
+			ereport(LOG,
+					(errmsg("starting archive recovery")));
+	}
+
 	if (read_backup_label(&checkPointLoc))
 	{
 		/*
@@ -5694,23 +5712,7 @@ StartupXLOG(void)
 		 * backup history file.
 		 */
 		if (InArchiveRecovery)
-		{
-			if (StandbyMode)
-				ereport(LOG,
-						(errmsg("entering standby mode")));
-			else if (recoveryTarget == RECOVERY_TARGET_XID)
-				ereport(LOG,
-					 (errmsg("starting point-in-time recovery to XID %u",
-							 recoveryTargetXid)));
-			else if (recoveryTarget == RECOVERY_TARGET_TIME)
-				ereport(LOG,
-						(errmsg("starting point-in-time recovery to %s",
-								timestamptz_to_str(recoveryTargetTime))));
-			else
-				ereport(LOG,
-						(errmsg("starting archive recovery")));
 			ControlFile->state = DB_IN_ARCHIVE_RECOVERY;
-		}
 		else
 		{
 			ereport(LOG,
-- 
GitLab