diff --git a/src/catalog.c b/src/catalog.c index 56bc72d7..52e2b759 100644 --- a/src/catalog.c +++ b/src/catalog.c @@ -35,6 +35,7 @@ timelineInfoNew(TimeLineID tli) tlinfo->tli = tli; tlinfo->switchpoint = InvalidXLogRecPtr; tlinfo->parent_link = NULL; + tlinfo->xlog_filelist = parray_new(); return tlinfo; } @@ -705,6 +706,7 @@ catalog_get_timelines(InstanceConfig *instance) pgFile *file = (pgFile *) parray_get(xlog_files_list, i); TimeLineID tli; parray *timelines; + xlogFile *wal_file = NULL; /* regular WAL file */ if (strspn(file->name, "0123456789ABCDEF") == XLOG_FNAME_LEN) @@ -731,7 +733,39 @@ catalog_get_timelines(InstanceConfig *instance) /* backup history file. Currently we don't use them */ if (IsBackupHistoryFileName(file->name)) { - elog(VERBOSE, "backup history file \"%s\". do nothing", file->name); + elog(VERBOSE, "backup history file \"%s\"", file->name); + + if (!tlinfo || tlinfo->tli != tli) + { + tlinfo = timelineInfoNew(tli); + parray_append(timelineinfos, tlinfo); + } + + /* append file to xlog file list */ + wal_file = palloc(sizeof(xlogFile)); + wal_file->file = *file; + wal_file->segno = segno; + wal_file->type = BACKUP_HISTORY_FILE; + parray_append(tlinfo->xlog_filelist, wal_file); + continue; + } + /* partial WAL segment */ + else if (IsPartialXLogFileName(file->name)) + { + elog(VERBOSE, "partial WAL file \"%s\"", file->name); + + if (!tlinfo || tlinfo->tli != tli) + { + tlinfo = timelineInfoNew(tli); + parray_append(timelineinfos, tlinfo); + } + + /* append file to xlog file list */ + wal_file = palloc(sizeof(xlogFile)); + wal_file->file = *file; + wal_file->segno = segno; + wal_file->type = PARTIAL_SEGMENT; + parray_append(tlinfo->xlog_filelist, wal_file); continue; } /* we only expect compressed wal files with .gz suffix */ @@ -779,6 +813,13 @@ catalog_get_timelines(InstanceConfig *instance) /* update counters */ tlinfo->n_xlog_files++; tlinfo->size += file->size; + + /* append file to xlog file list */ + wal_file = palloc(sizeof(xlogFile)); + wal_file->file = *file; + wal_file->segno = segno; + wal_file->type = SEGMENT; + parray_append(tlinfo->xlog_filelist, wal_file); } /* timeline history file */ else if (IsTLHistoryFileName(file->name)) @@ -847,8 +888,8 @@ catalog_get_timelines(InstanceConfig *instance) tlinfo->closest_backup = get_closest_backup(tlinfo, backups); } - parray_walk(xlog_files_list, pfree); - parray_free(xlog_files_list); + //parray_walk(xlog_files_list, pfree); + //parray_free(xlog_files_list); return timelineinfos; } diff --git a/src/pg_probackup.h b/src/pg_probackup.h index 7f02e9bf..38c32134 100644 --- a/src/pg_probackup.h +++ b/src/pg_probackup.h @@ -403,6 +403,8 @@ struct timelineInfo { size_t size; /* space on disk taken by regular WAL files */ parray *backups; /* array of pgBackup sturctures with info * about backups belonging to this timeline */ + parray *xlog_filelist; /* array of ordinary WAL segments, '.partial' + * and '.backup' files belonging to this timeline */ parray *lost_segments; /* array of intervals of lost segments */ pgBackup *closest_backup; /* link to backup, closest to timeline */ pgBackup *oldest_backup; /* link to oldest backup on timeline */ @@ -414,6 +416,20 @@ typedef struct xlogInterval XLogSegNo end_segno; } xlogInterval; +typedef enum xlogFileType +{ + SEGMENT, + PARTIAL_SEGMENT, + BACKUP_HISTORY_FILE +} xlogFileType; + +typedef struct xlogFile +{ + pgFile file; + XLogSegNo segno; + xlogFileType type; +} xlogFile; + /* * When copying datafiles to backup we validate and compress them block