aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2019-10-11 15:47:59 +0900
committerFujii Masao <fujii@postgresql.org>2019-10-11 15:49:32 +0900
commitfcf7f8d9242da9eb07e8a8de3d0d7fa3fd51ba1a (patch)
tree72a44a7a50d17f285b3ee9883c99e2c9a891114c
parent7ed1bcaed6ecbb0760169ea193cbe70071012576 (diff)
downloadpostgresql-fcf7f8d9242da9eb07e8a8de3d0d7fa3fd51ba1a.tar.gz
postgresql-fcf7f8d9242da9eb07e8a8de3d0d7fa3fd51ba1a.zip
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 2dedf4d9a8 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
-rw-r--r--src/backend/access/transam/xlog.c6
-rw-r--r--src/backend/access/transam/xlogarchive.c7
2 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index c2507e58187..a85aa835d38 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7606,7 +7606,10 @@ StartupXLOG(void)
}
else
CreateCheckPoint(CHECKPOINT_END_OF_RECOVERY | CHECKPOINT_IMMEDIATE);
+ }
+ if (ArchiveRecoveryRequested)
+ {
/*
* And finally, execute the recovery_end_command, if any.
*/
@@ -7614,10 +7617,7 @@ StartupXLOG(void)
ExecuteRecoveryCommand(recoveryEndCommand,
"recovery_end_command",
true);
- }
- if (ArchiveRecoveryRequested)
- {
/*
* We switched to a new timeline. Clean up segments on the old
* timeline.
diff --git a/src/backend/access/transam/xlogarchive.c b/src/backend/access/transam/xlogarchive.c
index 9a21f006d1d..e14bcf8ea60 100644
--- a/src/backend/access/transam/xlogarchive.c
+++ b/src/backend/access/transam/xlogarchive.c
@@ -64,6 +64,13 @@ RestoreArchivedFile(char *path, const char *xlogfname,
XLogRecPtr restartRedoPtr;
TimeLineID restartTli;
+ /*
+ * Ignore restore_command when not in archive recovery (meaning
+ * we are in crash recovery).
+ */
+ if (!ArchiveRecoveryRequested)
+ goto not_available;
+
/* In standby mode, restore_command might not be supplied */
if (recoveryRestoreCommand == NULL || strcmp(recoveryRestoreCommand, "") == 0)
goto not_available;