Skip to content

Commit 083cc49

Browse files
committed
Revert the patch to check if we've reached end-of-backup also when doing
crash recovery, and throw an error if not. hubert depesz lubaczewski pointed out that that situation also happens in the crash recovery following a system crash that happens during an online backup. We might want to do something smarter in 9.1, like put the check back for backups taken with pg_basebackup, but that's for another patch.
1 parent 052e621 commit 083cc49

File tree

1 file changed

+22
-5
lines changed
  • src/backend/access/transam

1 file changed

+22
-5
lines changed

src/backend/access/transam/xlog.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6322,12 +6322,28 @@ StartupXLOG(void)
63226322
(XLByteLT(EndOfLog, minRecoveryPoint) ||
63236323
!XLogRecPtrIsInvalid(ControlFile->backupStartPoint)))
63246324
{
6325-
if (reachedStopPoint) /* stopped because of stop request */
6325+
if (reachedStopPoint)
6326+
{
6327+
/* stopped because of stop request */
63266328
ereport(FATAL,
63276329
(errmsg("requested recovery stop point is before consistent recovery point")));
6328-
else /* ran off end of WAL */
6329-
ereport(FATAL,
6330-
(errmsg("WAL ends before consistent recovery point")));
6330+
}
6331+
else
6332+
{
6333+
/*
6334+
* Ran off end of WAL before reaching end-of-backup WAL record,
6335+
* or minRecoveryPoint. That's usually a bad sign, indicating that
6336+
* you tried to recover from an online backup but never called
6337+
* pg_stop_backup(), or you didn't archive all the WAL up to that
6338+
* point. However, this also happens in crash recovery, if the
6339+
* system crashes while an online backup is in progress. We
6340+
* must not treat that as an error, or the database will refuse
6341+
* to start up.
6342+
*/
6343+
if (InArchiveRecovery)
6344+
ereport(FATAL,
6345+
(errmsg("WAL ends before consistent recovery point")));
6346+
}
63316347
}
63326348

63336349
/*
@@ -7910,7 +7926,8 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
79107926
* record, the backup was cancelled and the end-of-backup record will
79117927
* never arrive.
79127928
*/
7913-
if (!XLogRecPtrIsInvalid(ControlFile->backupStartPoint))
7929+
if (InArchiveRecovery &&
7930+
!XLogRecPtrIsInvalid(ControlFile->backupStartPoint))
79147931
ereport(ERROR,
79157932
(errmsg("online backup was cancelled, recovery cannot continue")));
79167933

0 commit comments

Comments
 (0)