v1-0001-Disable-STARTUP_PROGRESS_TIMEOUT-in-standby-mode.patch

application/x-patch

Filename: v1-0001-Disable-STARTUP_PROGRESS_TIMEOUT-in-standby-mode.patch
Type: application/x-patch
Part: 0
Message: Re: when the startup process doesn't (logging startup delays)

Patch

Format: format-patch
Series: patch v1-0001
Subject: Disable STARTUP_PROGRESS_TIMEOUT in standby mode
File+
src/backend/access/transam/xlogrecovery.c 12 1
src/backend/postmaster/startup.c 2 0
From 40ac498a76f38903bbee37108812907a76bb1a78 Mon Sep 17 00:00:00 2001
From: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Date: Tue, 8 Nov 2022 12:18:11 +0000
Subject: [PATCH v1] Disable STARTUP_PROGRESS_TIMEOUT in standby mode

---
 src/backend/access/transam/xlogrecovery.c | 13 ++++++++++++-
 src/backend/postmaster/startup.c          |  2 ++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index cb07694aea..5326a98633 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -63,6 +63,7 @@
 #include "utils/pg_lsn.h"
 #include "utils/ps_status.h"
 #include "utils/pg_rusage.h"
+#include "utils/timeout.h"
 
 /* Unsupported old recovery command file names (relative to $PGDATA) */
 #define RECOVERY_COMMAND_FILE	"recovery.conf"
@@ -1653,7 +1654,17 @@ PerformWalRecovery(void)
 		 */
 		do
 		{
-			if (!StandbyMode)
+			/*
+			 * To avoid server log bloat, we don't report recovery progress in
+			 * a standby as it will always be in recovery unless promoted. We
+			 * also disable the timeout as we don't need it anymore.
+			 */
+			if (StandbyMode)
+			{
+				if (get_timeout_active(STARTUP_PROGRESS_TIMEOUT))
+					disable_timeout(STARTUP_PROGRESS_TIMEOUT, false);
+			}
+			else
 				ereport_startup_progress("redo in progress, elapsed time: %ld.%02d s, current LSN: %X/%X",
 										 LSN_FORMAT_ARGS(xlogreader->ReadRecPtr));
 
diff --git a/src/backend/postmaster/startup.c b/src/backend/postmaster/startup.c
index f99186eab7..1456e3ad3a 100644
--- a/src/backend/postmaster/startup.c
+++ b/src/backend/postmaster/startup.c
@@ -347,6 +347,8 @@ has_startup_progress_timeout_expired(long *secs, int *usecs)
 	int			useconds;
 	TimestampTz now;
 
+	Assert(get_timeout_active(STARTUP_PROGRESS_TIMEOUT) == true);
+
 	/* No timeout has occurred. */
 	if (!startup_progress_timer_expired)
 		return false;
-- 
2.34.1