diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index cdbe305..d1f93bb 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -230,6 +230,7 @@ static TimestampTz recoveryDelayUntilTime; static bool StandbyModeRequested = false; static char *PrimaryConnInfo = NULL; static char *PrimarySlotName = NULL; +static bool cancelBackupLabelOnFailure = false; static char *TriggerFile = NULL; /* are we currently in standby mode? */ @@ -5569,6 +5570,16 @@ readRecoveryCommandFile(void) ereport(DEBUG2, (errmsg("min_recovery_apply_delay = '%s'", item->value))); } + else if (strcmp(item->name, "cancel_backup_label_on_failure") == 0) + { + if (!parse_bool(item->value, &cancelBackupLabelOnFailure)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("parameter \"%s\" requires a Boolean value", + "cancel_backup_label_on_failure"))); + ereport(DEBUG2, + (errmsg_internal("cancel_backup_label_on_failure = '%s'", item->value))); + } else ereport(FATAL, (errmsg("unrecognized recovery parameter \"%s\"", @@ -7111,6 +7122,21 @@ StartupXLOG(void) record = ReadRecord(xlogreader, InvalidXLogRecPtr, LOG, false); } while (record != NULL); + if (cancelBackupLabelOnFailure && + ControlFile->backupStartPoint != InvalidXLogRecPtr) + { + /* + * Try to force complete recocovery when backup_label was + * found but end-of-backup record has not been found. + */ + + ControlFile->backupStartPoint = InvalidXLogRecPtr; + + ereport(WARNING, + (errmsg("backup_label was canceled."), + errhint("server might have crashed during backup mode."))); + CheckRecoveryConsistency(); + } /* * end of main redo apply loop */