@@ -239,7 +239,7 @@ do_backup_database(parray *backup_list)
239239
240240if (ptrack_lsn > prev_backup -> stop_lsn )
241241{
242- elog (ERROR ,"lsn from ptrack_control %lx differs fromlsn of previous ptrack backup %lx.\n"
242+ elog (ERROR ,"LSN from ptrack_control %lx differs fromLSN of previous ptrack backup %lx.\n"
243243"Create new full backup before an incremental one." ,
244244ptrack_lsn ,prev_backup -> start_lsn );
245245}
@@ -714,7 +714,8 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_oid,
714714}
715715
716716/*
717- * TODO Add comment
717+ * Wait for target 'lsn' to be archived in archive 'wal' directory with
718+ * WAL segment file.
718719 */
719720static void
720721wait_archive_lsn (XLogRecPtr lsn ,bool prev_segno )
@@ -729,7 +730,7 @@ wait_archive_lsn(XLogRecPtr lsn, bool prev_segno)
729730
730731tli = get_current_timeline (false);
731732
732- /* Compute the name of the WAL file containig requestedlsn */
733+ /* Compute the name of the WAL file containig requestedLSN */
733734XLByteToSeg (lsn ,targetSegNo );
734735if (prev_segno )
735736targetSegNo -- ;
@@ -747,14 +748,22 @@ wait_archive_lsn(XLogRecPtr lsn, bool prev_segno)
747748
748749/* Inform user if WAL segment is absent in first attempt */
749750if (try_count == 1 )
750- elog (INFO ,"wait forlsn %X/%X in archived WAL segment %s" ,
751+ elog (INFO ,"wait forLSN %X/%X in archived WAL segment %s" ,
751752 (uint32 ) (lsn >>32 ), (uint32 )lsn ,wal_path );
752753
753754if (archive_timeout > 0 && try_count > archive_timeout )
754755elog (ERROR ,
755756"switched WAL segment %s could not be archived in %d seconds" ,
756757wal_file ,archive_timeout );
757758}
759+
760+ /*
761+ * WAL segment was archived. Check LSN on it if we waited current WAL
762+ * segment, not previous.
763+ */
764+ if (!prev_segno && !wal_contains_lsn (arclog_path ,lsn ,tli ))
765+ elog (ERROR ,"WAL segment %s doesn't contain target LSN %X/%X" ,
766+ wal_file , (uint32 ) (lsn >>32 ), (uint32 )lsn );
758767}
759768
760769/*