@@ -33,6 +33,7 @@ static void restore_backup(pgBackup *backup);
3333static void create_recovery_conf (time_t backup_id ,
3434 pgRecoveryTarget * rt ,
3535 pgBackup * backup );
36+ static parray * read_timeline_history (TimeLineID targetTLI );
3637static void * restore_files (void * arg );
3738static void remove_deleted_files (pgBackup * backup );
3839
@@ -138,7 +139,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
138139
139140 elog (LOG , "target timeline ID = %u" , rt -> recovery_target_tli );
140141 /* Read timeline history files from archives */
141- timelines = readTimeLineHistory_probackup (rt -> recovery_target_tli );
142+ timelines = read_timeline_history (rt -> recovery_target_tli );
142143
143144 if (!satisfy_timeline (timelines , current_backup ))
144145 {
@@ -149,6 +150,9 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
149150 /* Try to find another backup that satisfies target timeline */
150151 continue ;
151152 }
153+
154+ parray_walk (timelines , pfree );
155+ parray_free (timelines );
152156 }
153157
154158 if (!satisfy_recovery_target (current_backup , rt ))
@@ -731,7 +735,7 @@ create_recovery_conf(time_t backup_id,
731735 * based on readTimeLineHistory() in timeline.c
732736 */
733737parray *
734- readTimeLineHistory_probackup (TimeLineID targetTLI )
738+ read_timeline_history (TimeLineID targetTLI )
735739{
736740 parray * result ;
737741 char path [MAXPGPATH ];
@@ -820,8 +824,7 @@ readTimeLineHistory_probackup(TimeLineID targetTLI)
820824 entry = pgut_new (TimeLineHistoryEntry );
821825 entry -> tli = targetTLI ;
822826 /* LSN in target timeline is valid */
823- /* TODO ensure that -1UL --> -1L fix is correct */
824- entry -> end = (uint32 ) (-1L << 32 ) | -1L ;
827+ entry -> end = InvalidXLogRecPtr ;
825828 parray_insert (result , 0 , entry );
826829
827830 return result ;
@@ -853,7 +856,8 @@ satisfy_timeline(const parray *timelines, const pgBackup *backup)
853856
854857 timeline = (TimeLineHistoryEntry * ) parray_get (timelines , i );
855858 if (backup -> tli == timeline -> tli &&
856- backup -> stop_lsn < timeline -> end )
859+ (XLogRecPtrIsInvalid (timeline -> end ) ||
860+ backup -> stop_lsn < timeline -> end ))
857861 return true;
858862 }
859863 return false;
0 commit comments