@@ -33,6 +33,7 @@ static void restore_backup(pgBackup *backup);
33
33
static void create_recovery_conf (time_t backup_id ,
34
34
pgRecoveryTarget * rt ,
35
35
pgBackup * backup );
36
+ static parray * read_timeline_history (TimeLineID targetTLI );
36
37
static void * restore_files (void * arg );
37
38
static void remove_deleted_files (pgBackup * backup );
38
39
@@ -138,7 +139,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
138
139
139
140
elog (LOG , "target timeline ID = %u" , rt -> recovery_target_tli );
140
141
/* Read timeline history files from archives */
141
- timelines = readTimeLineHistory_probackup (rt -> recovery_target_tli );
142
+ timelines = read_timeline_history (rt -> recovery_target_tli );
142
143
143
144
if (!satisfy_timeline (timelines , current_backup ))
144
145
{
@@ -149,6 +150,9 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
149
150
/* Try to find another backup that satisfies target timeline */
150
151
continue ;
151
152
}
153
+
154
+ parray_walk (timelines , pfree );
155
+ parray_free (timelines );
152
156
}
153
157
154
158
if (!satisfy_recovery_target (current_backup , rt ))
@@ -731,7 +735,7 @@ create_recovery_conf(time_t backup_id,
731
735
* based on readTimeLineHistory() in timeline.c
732
736
*/
733
737
parray *
734
- readTimeLineHistory_probackup (TimeLineID targetTLI )
738
+ read_timeline_history (TimeLineID targetTLI )
735
739
{
736
740
parray * result ;
737
741
char path [MAXPGPATH ];
@@ -820,8 +824,7 @@ readTimeLineHistory_probackup(TimeLineID targetTLI)
820
824
entry = pgut_new (TimeLineHistoryEntry );
821
825
entry -> tli = targetTLI ;
822
826
/* 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 ;
825
828
parray_insert (result , 0 , entry );
826
829
827
830
return result ;
@@ -853,7 +856,8 @@ satisfy_timeline(const parray *timelines, const pgBackup *backup)
853
856
854
857
timeline = (TimeLineHistoryEntry * ) parray_get (timelines , i );
855
858
if (backup -> tli == timeline -> tli &&
856
- backup -> stop_lsn < timeline -> end )
859
+ (XLogRecPtrIsInvalid (timeline -> end ) ||
860
+ backup -> stop_lsn < timeline -> end ))
857
861
return true;
858
862
}
859
863
return false;
0 commit comments