From 43a72954a7bafe9297c22fd3d57fbe9f0f21746e Mon Sep 17 00:00:00 2001 From: Nitin Jadhav Date: Mon, 9 Nov 2026 04:42:11 +0000 Subject: [PATCH] Report standby replay progress before consistency Standby mode currently suppresses WAL replay progress because recovery can continue indefinitely. This also hides progress while a standby is still starting and has not yet reached consistency. Enable the existing startup progress reporting during that bounded interval. Disable its timer as soon as consistency is reached, preserving the existing behavior for normal long-running standby replay. Always cancel the startup progress timeout regardless of the current setting, so reloading the interval to zero cannot leave an active timer running after consistency. --- doc/src/sgml/config.sgml | 3 ++- src/backend/access/transam/xlogrecovery.c | 13 +++++-------- src/backend/postmaster/startup.c | 4 ---- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index a6a2df177f2..683e122dd72 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -7777,7 +7777,8 @@ local0.* /var/log/postgresql operation. The default is 10 seconds. A setting of 0 disables the feature. If this value is specified without units, it is taken as milliseconds. This setting is applied separately to - each operation. + each operation. During WAL replay on a standby server, progress is + reported only until the standby reaches a consistent recovery state. This parameter can only be set in the postgresql.conf file or on the server command line. diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index 52ac6d58423..1f6ee3bbc58 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -427,12 +427,7 @@ EnableStandbyMode(void) { StandbyMode = true; - /* - * To avoid server log bloat, we don't report recovery progress in a - * standby as it will always be in recovery unless promoted. We disable - * startup progress timeout in standby mode to avoid calling - * startup_progress_timeout_handler() unnecessarily. - */ + /* Disable any timeout left active by an earlier startup phase. */ disable_startup_progress_timeout(); } @@ -1724,7 +1719,7 @@ PerformWalRecovery(void) LSN_FORMAT_ARGS(xlogreader->ReadRecPtr))); /* Prepare to report progress of the redo phase. */ - if (!StandbyMode) + if (!StandbyMode || !reachedConsistency) begin_startup_progress_phase(); /* @@ -1732,7 +1727,7 @@ PerformWalRecovery(void) */ do { - if (!StandbyMode) + if (!StandbyMode || !reachedConsistency) ereport_startup_progress("redo in progress, elapsed time: %ld.%02d s, current LSN: %X/%08X", LSN_FORMAT_ARGS(xlogreader->ReadRecPtr)); @@ -2243,6 +2238,8 @@ CheckRecoveryConsistency(void) CheckTablespaceDirectory(); reachedConsistency = true; + if (StandbyMode) + disable_startup_progress_timeout(); SendPostmasterSignal(PMSIGNAL_RECOVERY_CONSISTENT); ereport(LOG, errmsg("consistent recovery state reached at %X/%08X", diff --git a/src/backend/postmaster/startup.c b/src/backend/postmaster/startup.c index d91b7caac01..10adc92c332 100644 --- a/src/backend/postmaster/startup.c +++ b/src/backend/postmaster/startup.c @@ -307,10 +307,6 @@ startup_progress_timeout_handler(void) void disable_startup_progress_timeout(void) { - /* Feature is disabled. */ - if (log_startup_progress_interval == 0) - return; - disable_timeout(STARTUP_PROGRESS_TIMEOUT, false); startup_progress_timer_expired = false; } -- 2.43.0