mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-23 11:45:36 +02:00
[Issue #326] Handle empty history files correctly
This commit is contained in:
parent
294e7dc205
commit
74cd9c54df
@ -1581,6 +1581,10 @@ catalog_get_timelines(InstanceConfig *instance)
|
||||
sscanf(file->name, "%08X.history", &tli);
|
||||
timelines = read_timeline_history(arclog_path, tli, true);
|
||||
|
||||
/* History file is empty or corrupted, disregard it */
|
||||
if (!timelines)
|
||||
continue;
|
||||
|
||||
if (!tlinfo || tlinfo->tli != tli)
|
||||
{
|
||||
tlinfo = timelineInfoNew(tli);
|
||||
|
@ -289,6 +289,9 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
|
||||
/* Read timeline history files from archives */
|
||||
timelines = read_timeline_history(arclog_path, rt->target_tli, true);
|
||||
|
||||
if (!timelines)
|
||||
elog(WARNING, "Failed to get history file for target timeline %i", rt->target_tli);
|
||||
|
||||
if (!satisfy_timeline(timelines, current_backup))
|
||||
{
|
||||
if (target_backup_id != INVALID_BACKUP_ID)
|
||||
@ -1778,6 +1781,14 @@ read_timeline_history(const char *arclog_path, TimeLineID targetTLI, bool strict
|
||||
if (last_timeline && targetTLI <= last_timeline->tli)
|
||||
elog(ERROR, "Timeline IDs must be less than child timeline's ID.");
|
||||
|
||||
/* History file is empty or corrupted */
|
||||
if (parray_num(result) != 1)
|
||||
{
|
||||
elog(WARNING, "History file is corrupted: \"%s\"", path);
|
||||
pg_free(result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* append target timeline */
|
||||
entry = pgut_new(TimeLineHistoryEntry);
|
||||
entry->tli = targetTLI;
|
||||
|
Loading…
x
Reference in New Issue
Block a user