Skip to content

Commit 54685b1

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 b5bb040 commit 54685b1

File tree

1 file changed

+26
-10
lines changed
  • src/backend/access/transam

1 file changed

+26
-10
lines changed

src/backend/access/transam/xlog.c

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6651,17 +6651,32 @@ StartupXLOG(void)
66516651
(XLByteLT(EndOfLog, minRecoveryPoint) ||
66526652
!XLogRecPtrIsInvalid(ControlFile->backupStartPoint)))
66536653
{
6654-
if (reachedStopPoint) /* stopped because of stop request */
6654+
if (reachedStopPoint)
6655+
{
6656+
/* stopped because of stop request */
66556657
ereport(FATAL,
66566658
(errmsg("requested recovery stop point is before consistent recovery point")));
6657-
/* ran off end of WAL */
6658-
if (!XLogRecPtrIsInvalid(ControlFile->backupStartPoint))
6659-
ereport(FATAL,
6660-
(errmsg("WAL ends before end of online backup"),
6661-
errhint("Online backup started with pg_start_backup() must be ended with pg_stop_backup(), and all WAL up to that point must be available at recovery.")));
6662-
else
6663-
ereport(FATAL,
6664-
(errmsg("WAL ends before consistent recovery point")));
6659+
}
6660+
/*
6661+
* Ran off end of WAL before reaching end-of-backup WAL record,
6662+
* or minRecoveryPoint. That's usually a bad sign, indicating that
6663+
* you tried to recover from an online backup but never called
6664+
* pg_stop_backup(), or you didn't archive all the WAL up to that
6665+
* point. However, this also happens in crash recovery, if the
6666+
* system crashes while an online backup is in progress. We
6667+
* must not treat that as an error, or the database will refuse
6668+
* to start up.
6669+
*/
6670+
if (InArchiveRecovery)
6671+
{
6672+
if (!XLogRecPtrIsInvalid(ControlFile->backupStartPoint))
6673+
ereport(FATAL,
6674+
(errmsg("WAL ends before end of online backup"),
6675+
errhint("Online backup started with pg_start_backup() must be ended with pg_stop_backup(), and all WAL up to that point must be available at recovery.")));
6676+
else
6677+
ereport(FATAL,
6678+
(errmsg("WAL ends before consistent recovery point")));
6679+
}
66656680
}
66666681

66676682
/*
@@ -8353,7 +8368,8 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
83538368
* record, the backup was cancelled and the end-of-backup record will
83548369
* never arrive.
83558370
*/
8356-
if (!XLogRecPtrIsInvalid(ControlFile->backupStartPoint))
8371+
if (InArchiveRecovery &&
8372+
!XLogRecPtrIsInvalid(ControlFile->backupStartPoint))
83578373
ereport(ERROR,
83588374
(errmsg("online backup was cancelled, recovery cannot continue")));
83598375

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy