@@ -67,6 +67,8 @@ static bool stop_streaming(XLogRecPtr xlogpos, uint32 timeline,
67
67
static void add_walsegment_to_filelist (parray * filelist , uint32 timeline ,
68
68
XLogRecPtr xlogpos , char * basedir ,
69
69
uint32 xlog_seg_size );
70
+ static void add_history_file_to_filelist (parray * filelist , uint32 timeline ,
71
+ char * basedir );
70
72
71
73
/*
72
74
* Run IDENTIFY_SYSTEM through a given connection and
@@ -255,6 +257,9 @@ StreamLog(void *arg)
255
257
stop_stream_lsn , (char * ) stream_arg -> basedir ,
256
258
instance_config .xlog_seg_size );
257
259
260
+ /* append history file to walsegment filelist */
261
+ add_history_file_to_filelist (xlog_files_list , stream_arg -> starttli , (char * ) stream_arg -> basedir );
262
+
258
263
/*
259
264
* TODO: remove redundant WAL segments
260
265
* 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)
398
403
void
399
404
add_walsegment_to_filelist (parray * filelist , uint32 timeline , XLogRecPtr xlogpos , char * basedir , uint32 xlog_seg_size )
400
405
{
401
- XLogSegNo xlog_segno ;
406
+ XLogSegNo xlog_segno ;
402
407
char wal_segment_name [MAXFNAMELEN ];
403
408
char wal_segment_relpath [MAXPGPATH ];
404
409
char wal_segment_fullpath [MAXPGPATH ];
@@ -451,3 +456,32 @@ add_walsegment_to_filelist(parray *filelist, uint32 timeline, XLogRecPtr xlogpos
451
456
/* append file to filelist */
452
457
parray_append (filelist , file );
453
458
}
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