Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 20961ce

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 06a367c commit 20961ce

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/backend/access/transam/xlog.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -7610,18 +7610,18 @@ StartupXLOG(void)
76107610
}
76117611
else
76127612
CreateCheckPoint(CHECKPOINT_END_OF_RECOVERY | CHECKPOINT_IMMEDIATE);
7613+
}
76137614

7615+
if (ArchiveRecoveryRequested)
7616+
{
76147617
/*
76157618
* And finally, execute the recovery_end_command, if any.
76167619
*/
76177620
if (recoveryEndCommand && strcmp(recoveryEndCommand, "") != 0)
76187621
ExecuteRecoveryCommand(recoveryEndCommand,
76197622
"recovery_end_command",
76207623
true);
7621-
}
76227624

7623-
if (ArchiveRecoveryRequested)
7624-
{
76257625
/*
76267626
* We switched to a new timeline. Clean up segments on the old
76277627
* timeline.

src/backend/access/transam/xlogarchive.c

+7
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)