@@ -67,6 +67,8 @@ static bool stop_streaming(XLogRecPtr xlogpos, uint32 timeline,
6767static void add_walsegment_to_filelist (parray * filelist , uint32 timeline ,
6868 XLogRecPtr xlogpos , char * basedir ,
6969 uint32 xlog_seg_size );
70+ static void add_history_file_to_filelist (parray * filelist , uint32 timeline ,
71+ char * basedir );
7072
7173/*
7274 * Run IDENTIFY_SYSTEM through a given connection and
@@ -255,6 +257,9 @@ StreamLog(void *arg)
255257 stop_stream_lsn , (char * ) stream_arg -> basedir ,
256258 instance_config .xlog_seg_size );
257259
260+ /* append history file to walsegment filelist */
261+ add_history_file_to_filelist (xlog_files_list , stream_arg -> starttli , (char * ) stream_arg -> basedir );
262+
258263 /*
259264 * TODO: remove redundant WAL segments
260265 * walk pg_wal and remove files with segno greater that of stop_lsn`s segno +1
@@ -398,7 +403,7 @@ wait_WAL_streaming_end(parray *backup_files_list)
398403void
399404add_walsegment_to_filelist (parray * filelist , uint32 timeline , XLogRecPtr xlogpos , char * basedir , uint32 xlog_seg_size )
400405{
401- XLogSegNo xlog_segno ;
406+ XLogSegNo xlog_segno ;
402407 char wal_segment_name [MAXFNAMELEN ];
403408 char wal_segment_relpath [MAXPGPATH ];
404409 char wal_segment_fullpath [MAXPGPATH ];
@@ -451,3 +456,32 @@ add_walsegment_to_filelist(parray *filelist, uint32 timeline, XLogRecPtr xlogpos
451456 /* append file to filelist */
452457 parray_append (filelist , file );
453458}
459+
460+ /* Append streamed WAL segment to filelist */
461+ void
462+ add_history_file_to_filelist (parray * filelist , uint32 timeline , char * basedir )
463+ {
464+ char filename [MAXFNAMELEN ];
465+ char fullpath [MAXPGPATH ];
466+ char relpath [MAXPGPATH ];
467+ pgFile * file = NULL ;
468+
469+ /* Timeline 1 does not have a history file */
470+ if (timeline == 1 )
471+ return ;
472+
473+ snprintf (filename , lengthof (filename ), "%08X.history" , timeline );
474+ join_path_components (fullpath , basedir , filename );
475+ join_path_components (relpath , PG_XLOG_DIR , filename );
476+
477+ file = pgFileNew (fullpath , relpath , false, 0 , FIO_BACKUP_HOST );
478+ file -> name = file -> rel_path ;
479+
480+ /* calculate crc */
481+ file -> crc = pgFileGetCRC (fullpath , true, false);
482+ file -> write_size = file -> size ;
483+ file -> uncompressed_size = file -> size ;
484+
485+ /* append file to filelist */
486+ parray_append (filelist , file );
487+ }
0 commit comments