Skip to content

Commit ac4519e

Browse files
committed
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.
1 parent b3aa4cf commit ac4519e

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

parsexlog.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,20 +315,27 @@ validate_wal(pgBackup *backup,
315315

316316
free(backup_id);
317317

318-
/* If recovery target is provided, ensure that archive exists. */
319-
if (dir_is_empty(archivedir)
320-
&& (TransactionIdIsValid(target_xid) || target_time != 0))
321-
elog(ERROR, "WAL archive is empty. You cannot restore backup to a recovery target without WAL archive.");
318+
/*
319+
* If recovery target is provided check that we can restore backup to a
320+
* recoverty target time or xid.
321+
*/
322+
if (!TransactionIdIsValid(target_xid) || target_time == 0)
323+
/* Recoverty target is not given so exit */
324+
return;
325+
326+
/*
327+
* If recovery target is provided, ensure that archive files exist in
328+
* archive directory.
329+
*/
330+
if (dir_is_empty(archivedir))
331+
elog(ERROR, "WAL archive is empty. You cannot restore backup to a recovery target without WAL archive.");
322332

323333
/*
324334
* Check if we have in archive all files needed to restore backup
325335
* up to the given recovery target.
326336
* In any case we cannot restore to the point before stop_lsn.
327337
*/
328-
if (backup->stream)
329-
private.archivedir = backup_xlog_path;
330-
else
331-
private.archivedir = archivedir;
338+
private.archivedir = archivedir;
332339

333340
private.tli = tli;
334341
xlogreader = XLogReaderAllocate(&SimpleXLogPageRead, &private);

0 commit comments

Comments
 (0)