*** a/src/backend/access/transam/xlog.c --- b/src/backend/access/transam/xlog.c *************** *** 6412,6432 **** StartupXLOG(void) * 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. */ if (haveBackupLabel) { ! ControlFile->backupStartPoint = checkPoint.redo; ! ControlFile->backupEndRequired = backupEndRequired; ! ! if (backupFromStandby) { ! if (dbstate_at_startup != DB_IN_ARCHIVE_RECOVERY) ! ereport(FATAL, ! (errmsg("backup_label contains data inconsistent with control file"), ! errhint("This means that the backup is corrupted and you will " ! "have to use another backup for recovery."))); ! ControlFile->backupEndPoint = ControlFile->minRecoveryPoint; } } ControlFile->time = (pg_time_t) time(NULL); /* No need to hold ControlFileLock yet, we aren't up far enough */ --- 6412,6445 ---- * 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. + * + * If we're beginning at a shutdown checkpoint, we know that nothing + * was running on the master at this point and the data on disk is now + * consistent. So we don't need to set any ControlFile fields required + * for checking whether we've reached a consistent database state. */ if (haveBackupLabel) { ! if (wasShutdown) { ! MemSet(&ControlFile->backupStartPoint, 0, sizeof(XLogRecPtr)); ! MemSet(&ControlFile->backupEndPoint, 0, sizeof(XLogRecPtr)); ! ControlFile->backupEndRequired = false; ! } ! else ! { ! ControlFile->backupStartPoint = checkPoint.redo; ! ControlFile->backupEndRequired = backupEndRequired; ! if (backupFromStandby) ! ControlFile->backupEndPoint = ControlFile->minRecoveryPoint; } + + if (backupFromStandby && dbstate_at_startup != DB_IN_ARCHIVE_RECOVERY) + ereport(FATAL, + (errmsg("backup_label contains data inconsistent with control file"), + errhint("This means that the backup is corrupted and you will " + "have to use another backup for recovery."))); + } ControlFile->time = (pg_time_t) time(NULL); /* No need to hold ControlFileLock yet, we aren't up far enough */