mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Fail if recovery target is not reached
Before, if a recovery target is configured, but the archive ended before the target was reached, recovery would end and the server would promote without further notice. That was deemed to be pretty wrong. With this change, if the recovery target is not reached, it is a fatal error. Based-on-patch-by: Leif Gunnar Erlandsen <leif@lako.no> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/993736dd3f1713ec1f63fc3b653839f5@lako.no
This commit is contained in:
@ -6200,7 +6200,7 @@ StartupXLOG(void)
|
||||
XLogCtlInsert *Insert;
|
||||
CheckPoint checkPoint;
|
||||
bool wasShutdown;
|
||||
bool reachedStopPoint = false;
|
||||
bool reachedRecoveryTarget = false;
|
||||
bool haveBackupLabel = false;
|
||||
bool haveTblspcMap = false;
|
||||
XLogRecPtr RecPtr,
|
||||
@ -7103,7 +7103,7 @@ StartupXLOG(void)
|
||||
*/
|
||||
if (recoveryStopsBefore(xlogreader))
|
||||
{
|
||||
reachedStopPoint = true; /* see below */
|
||||
reachedRecoveryTarget = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -7258,7 +7258,7 @@ StartupXLOG(void)
|
||||
/* Exit loop if we reached inclusive recovery target */
|
||||
if (recoveryStopsAfter(xlogreader))
|
||||
{
|
||||
reachedStopPoint = true;
|
||||
reachedRecoveryTarget = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -7270,7 +7270,7 @@ StartupXLOG(void)
|
||||
* end of main redo apply loop
|
||||
*/
|
||||
|
||||
if (reachedStopPoint)
|
||||
if (reachedRecoveryTarget)
|
||||
{
|
||||
if (!reachedConsistency)
|
||||
ereport(FATAL,
|
||||
@ -7327,7 +7327,18 @@ StartupXLOG(void)
|
||||
/* there are no WAL records following the checkpoint */
|
||||
ereport(LOG,
|
||||
(errmsg("redo is not required")));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* This check is intentionally after the above log messages that
|
||||
* indicate how far recovery went.
|
||||
*/
|
||||
if (ArchiveRecoveryRequested &&
|
||||
recoveryTarget != RECOVERY_TARGET_UNSET &&
|
||||
!reachedRecoveryTarget)
|
||||
ereport(FATAL,
|
||||
(errmsg("recovery ended before configured recovery target was reached")));
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user