Skip to content

Commit fcf7f8d

Browse files
committed
Make crash recovery ignore restore_command and recovery_end_command settings.
In v11 or before, those settings could not take effect in crash recovery because they are specified in recovery.conf and crash recovery always starts without recovery.conf. But commit 2dedf4d integrated recovery.conf into postgresql.conf and which unexpectedly allowed those settings to take effect even in crash recovery. This is definitely not good behavior. To fix the issue, this commit makes crash recovery always ignore restore_command and recovery_end_command settings. Back-patch to v12 where the issue was added. Author: Fujii Masao Reviewed-by: Peter Eisentraut Discussion: https://postgr.es/m/e445616d-023e-a268-8aa1-67b8b335340c@pgmasters.net
1 parent 7ed1bca commit fcf7f8d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/backend/access/transam/xlog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7606,18 +7606,18 @@ StartupXLOG(void)
76067606
}
76077607
else
76087608
CreateCheckPoint(CHECKPOINT_END_OF_RECOVERY | CHECKPOINT_IMMEDIATE);
7609+
}
76097610

7611+
if (ArchiveRecoveryRequested)
7612+
{
76107613
/*
76117614
* And finally, execute the recovery_end_command, if any.
76127615
*/
76137616
if (recoveryEndCommand && strcmp(recoveryEndCommand, "") != 0)
76147617
ExecuteRecoveryCommand(recoveryEndCommand,
76157618
"recovery_end_command",
76167619
true);
7617-
}
76187620

7619-
if (ArchiveRecoveryRequested)
7620-
{
76217621
/*
76227622
* We switched to a new timeline. Clean up segments on the old
76237623
* timeline.

src/backend/access/transam/xlogarchive.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ RestoreArchivedFile(char *path, const char *xlogfname,
6464
XLogRecPtr restartRedoPtr;
6565
TimeLineID restartTli;
6666

67+
/*
68+
* Ignore restore_command when not in archive recovery (meaning
69+
* we are in crash recovery).
70+
*/
71+
if (!ArchiveRecoveryRequested)
72+
goto not_available;
73+
6774
/* In standby mode, restore_command might not be supplied */
6875
if (recoveryRestoreCommand == NULL || strcmp(recoveryRestoreCommand, "") == 0)
6976
goto not_available;

0 commit comments

Comments
 (0)