Skip to content

Commit 8350e17

Browse files
committed
[Issue #283] add history file to STREAM backup filelist
1 parent da50370 commit 8350e17

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

src/pg_probackup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,8 +995,8 @@ extern void fio_pgFileDelete(pgFile *file, const char *full_path);
995995

996996
extern void pgFileFree(void *file);
997997

998-
extern pg_crc32 pgFileGetCRC(const char *file_path, bool missing_ok, bool use_crc32c);
999-
extern pg_crc32 pgFileGetCRCgz(const char *file_path, bool missing_ok, bool use_crc32c);
998+
extern pg_crc32 pgFileGetCRC(const char *file_path, bool use_crc32c, bool missing_ok);
999+
extern pg_crc32 pgFileGetCRCgz(const char *file_path, bool use_crc32c, bool missing_ok);
10001000

10011001
extern int pgFileMapComparePath(const void *f1, const void *f2);
10021002
extern int pgFileCompareName(const void *f1, const void *f2);

src/stream.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ static bool stop_streaming(XLogRecPtr xlogpos, uint32 timeline,
6767
static 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)
398403
void
399404
add_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

Comments
 (0)