diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0f09add784..aaa8ef423c 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6070,11 +6070,17 @@ StartupXLOG(void) /* * Set backupStartPoint if we're starting recovery from a base backup. * - * Set backupEndPoint and use minRecoveryPoint as the backup end + * Also set backupEndPoint and use minRecoveryPoint as the backup end * location if we're starting recovery from a base backup which was - * taken from the standby. In this case, the database system status in - * pg_control must indicate DB_IN_ARCHIVE_RECOVERY. If not, which - * means that backup is corrupted, so we cancel recovery. + * taken from a standby. In this case, the database system status in + * pg_control must indicate that the database was already in + * recovery. Usually that will be DB_IN_ARCHIVE_RECOVERY but also can + * be DB_SHUTDOWNED_IN_RECOVERY if recovery previously was interrupted + * before reaching this point; e.g. because restore_command or + * primary_conninfo were faulty. + * + * Any other state indicates that the backup somehow became corrupted + * and we can't sensibly continue with recovery. */ if (haveBackupLabel) { @@ -6083,7 +6089,8 @@ StartupXLOG(void) if (backupFromStandby) { - if (dbstate_at_startup != DB_IN_ARCHIVE_RECOVERY) + if (dbstate_at_startup != DB_IN_ARCHIVE_RECOVERY && + dbstate_at_startup != DB_SHUTDOWNED_IN_RECOVERY) ereport(FATAL, (errmsg("backup_label contains data inconsistent with control file"), errhint("This means that the backup is corrupted and you will "