@@ -519,6 +519,7 @@ validate_wal(pgBackup *backup, const char *archivedir,
519
519
TimestampTz last_time = 0 ;
520
520
char last_timestamp [100 ],
521
521
target_timestamp [100 ];
522
+ XLogRecPtr last_lsn = InvalidXLogRecPtr ;
522
523
bool all_wal = false;
523
524
char backup_xlog_path [MAXPGPATH ];
524
525
@@ -585,6 +586,7 @@ validate_wal(pgBackup *backup, const char *archivedir,
585
586
/* We can restore at least up to the backup end */
586
587
time2iso (last_timestamp , lengthof (last_timestamp ), backup -> recovery_time );
587
588
last_xid = backup -> recovery_xid ;
589
+ last_lsn = backup -> stop_lsn ;
588
590
589
591
if ((TransactionIdIsValid (target_xid ) && target_xid == last_xid )
590
592
|| (target_time != 0 && backup -> recovery_time >= target_time )
@@ -608,6 +610,7 @@ validate_wal(pgBackup *backup, const char *archivedir,
608
610
timestamp_record = getRecordTimestamp (xlogreader , & last_time );
609
611
if (XLogRecGetXid (xlogreader ) != InvalidTransactionId )
610
612
last_xid = XLogRecGetXid (xlogreader );
613
+ last_lsn = xlogreader -> ReadRecPtr ;
611
614
612
615
/* Check target xid */
613
616
if (TransactionIdIsValid (target_xid ) && target_xid == last_xid )
@@ -616,12 +619,19 @@ validate_wal(pgBackup *backup, const char *archivedir,
616
619
break ;
617
620
}
618
621
/* Check target time */
619
- else if (target_time != 0 && timestamp_record && timestamptz_to_time_t (last_time ) >= target_time )
622
+ else if (target_time != 0 && timestamp_record &&
623
+ timestamptz_to_time_t (last_time ) >= target_time )
620
624
{
621
625
all_wal = true;
622
626
break ;
623
627
}
624
- /* If there are no target xid and target time */
628
+ /* Check target lsn */
629
+ else if (XRecOffIsValid (target_xid ) && last_lsn >= target_lsn )
630
+ {
631
+ all_wal = true;
632
+ break ;
633
+ }
634
+ /* If there are no target xid, target time and target lsn */
625
635
else if (!TransactionIdIsValid (target_xid ) && target_time == 0 &&
626
636
xlogreader -> ReadRecPtr == backup -> stop_lsn )
627
637
{
@@ -638,15 +648,17 @@ validate_wal(pgBackup *backup, const char *archivedir,
638
648
639
649
/* There are all needed WAL records */
640
650
if (all_wal )
641
- elog (INFO , "backup validation completed successfully on time %s and xid " XID_FMT ,
642
- last_timestamp , last_xid );
651
+ elog (INFO , "backup validation completed successfully on time %s, xid " XID_FMT " and LSN %X/%X" ,
652
+ last_timestamp , last_xid ,
653
+ (uint32 ) (last_lsn >> 32 ), (uint32 ) last_lsn );
643
654
/* Some needed WAL records are absent */
644
655
else
645
656
{
646
657
PrintXLogCorruptionMsg (& private , WARNING );
647
658
648
- elog (WARNING , "recovery can be done up to time %s and xid " XID_FMT ,
649
- last_timestamp , last_xid );
659
+ elog (WARNING , "recovery can be done up to time %s, xid " XID_FMT " and LSN %X/%X" ,
660
+ last_timestamp , last_xid ,
661
+ (uint32 ) (last_lsn >> 32 ), (uint32 ) last_lsn );
650
662
651
663
if (target_time > 0 )
652
664
time2iso (target_timestamp , lengthof (target_timestamp ),
0 commit comments