From 220ac45364ab30aa996d8f263abecb4e9a810ffc Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Tue, 10 Feb 2026 11:49:46 +0900 Subject: [PATCH v1] Remove recovery.signal at recovery end when both signal files are present. When both standby.signal and recovery.signal are present, standby.signal takes precedence and the server runs in standby mode. Previously, in this case, recovery.signal was not removed at the end of standby mode (i.e., on promotion) or at the end of archive recovery, while standby.signal was removed. As a result, a leftover recovery.signal could cause a subsequent restart to enter archive recovery unexpectedly, potentially preventing the server from starting. This behavior was surprising and confusing to users. This commit fixes the issue by updating the recovery code to remove recovery.signal alongside standby.signal when both files are present and recovery completes. Because this code path is particularly sensitive and changes in recovery behavior can be risky for stable branches, this change is applied only to the master branch. --- src/backend/access/transam/xlogrecovery.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index 4fc37a031d9..eca17d354f9 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -1068,9 +1068,6 @@ readRecoverySignalFile(void) * Check for recovery signal files and if found, fsync them since they * represent server state information. We don't sweat too much about the * possibility of fsync failure, however. - * - * If present, standby signal file takes precedence. If neither is present - * then we won't enter archive recovery. */ if (stat(STANDBY_SIGNAL_FILE, &stat_buf) == 0) { @@ -1085,7 +1082,8 @@ readRecoverySignalFile(void) } standby_signal_file_found = true; } - else if (stat(RECOVERY_SIGNAL_FILE, &stat_buf) == 0) + + if (stat(RECOVERY_SIGNAL_FILE, &stat_buf) == 0) { int fd; @@ -1099,6 +1097,11 @@ readRecoverySignalFile(void) recovery_signal_file_found = true; } + /* + * + * If both signal files are present, standby signal file takes precedence. + * If neither is present then we won't enter archive recovery. + */ StandbyModeRequested = false; ArchiveRecoveryRequested = false; if (standby_signal_file_found) -- 2.51.2