From ac4519e33c3d6ad3acf8b7632808d47bb71af5b8 Mon Sep 17 00:00:00 2001 From: Arthur Zakirov Date: Thu, 15 Jun 2017 15:52:08 +0300 Subject: [PATCH] Fixes for validate_wal(). For stream backup check only WAL segments from start_lsn to stop_lsn. If recovery target is provided check that we can restore backup to a recoverty target time or xid. --- parsexlog.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/parsexlog.c b/parsexlog.c index c5dee7e9..0925e559 100644 --- a/parsexlog.c +++ b/parsexlog.c @@ -315,20 +315,27 @@ validate_wal(pgBackup *backup, free(backup_id); - /* If recovery target is provided, ensure that archive exists. */ - if (dir_is_empty(archivedir) - && (TransactionIdIsValid(target_xid) || target_time != 0)) - elog(ERROR, "WAL archive is empty. You cannot restore backup to a recovery target without WAL archive."); + /* + * If recovery target is provided check that we can restore backup to a + * recoverty target time or xid. + */ + if (!TransactionIdIsValid(target_xid) || target_time == 0) + /* Recoverty target is not given so exit */ + return; + + /* + * If recovery target is provided, ensure that archive files exist in + * archive directory. + */ + if (dir_is_empty(archivedir)) + elog(ERROR, "WAL archive is empty. You cannot restore backup to a recovery target without WAL archive."); /* * Check if we have in archive all files needed to restore backup * up to the given recovery target. * In any case we cannot restore to the point before stop_lsn. */ - if (backup->stream) - private.archivedir = backup_xlog_path; - else - private.archivedir = archivedir; + private.archivedir = archivedir; private.tli = tli; xlogreader = XLogReaderAllocate(&SimpleXLogPageRead, &private);