mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-19 11:30:07 +02:00
Little optimization, remove unnecessary find_direct_child()
This commit is contained in:
parent
6b6491e3b7
commit
0fbbc22c6a
@ -1026,13 +1026,14 @@ is_prolific(parray *backup_list, pgBackup *target_backup)
|
||||
if (tmp_backup->parent_backup == target_backup->start_time &&
|
||||
(tmp_backup->status == BACKUP_STATUS_OK ||
|
||||
tmp_backup->status == BACKUP_STATUS_DONE))
|
||||
{
|
||||
child_counter++;
|
||||
if (child_counter > 1)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (child_counter > 1)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1067,35 +1068,6 @@ find_parent_full_backup(pgBackup *current_backup)
|
||||
return base_full_backup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find closest child of target_backup. If there are several direct
|
||||
* offsprings in backup_list, then first win.
|
||||
*/
|
||||
pgBackup*
|
||||
find_direct_child(parray *backup_list, pgBackup *target_backup)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < parray_num(backup_list); i++)
|
||||
{
|
||||
pgBackup *tmp_backup = (pgBackup *) parray_get(backup_list, i);
|
||||
|
||||
if (tmp_backup->backup_mode == BACKUP_MODE_FULL)
|
||||
continue;
|
||||
|
||||
/* Consider only OK and DONE children */
|
||||
if (tmp_backup->parent_backup == target_backup->start_time &&
|
||||
(tmp_backup->status == BACKUP_STATUS_OK ||
|
||||
tmp_backup->status == BACKUP_STATUS_DONE))
|
||||
{
|
||||
return tmp_backup;
|
||||
}
|
||||
}
|
||||
elog(WARNING, "Failed to find a direct child for backup %s",
|
||||
base36enc(target_backup->start_time));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Interate over parent chain and look for any problems.
|
||||
* Return 0 if chain is broken.
|
||||
@ -1204,4 +1176,4 @@ get_backup_index_number(parray *backup_list, pgBackup *backup)
|
||||
}
|
||||
elog(WARNING, "Failed to find backup %s", base36enc(backup->start_time));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +129,9 @@ int do_retention(void)
|
||||
bool retention_is_set = false; /* At least one retention policy is set */
|
||||
bool backup_list_is_empty = false;
|
||||
|
||||
backup_deleted = false;
|
||||
backup_merged = false;
|
||||
|
||||
/* Get a complete list of backups. */
|
||||
backup_list = catalog_get_backup_list(INVALID_BACKUP_ID);
|
||||
|
||||
@ -411,7 +414,7 @@ do_retention_merge(parray *backup_list, parray *to_keep_list, parray *to_purge_l
|
||||
continue;
|
||||
}
|
||||
|
||||
/* FULL backup in purge list, thanks to sparsing of keep_list current backup is
|
||||
/* FULL backup in purge list, thanks to sparsing of keep_list current backup is
|
||||
* final target for merge, but there could be intermediate incremental
|
||||
* backups from purge_list.
|
||||
*/
|
||||
|
@ -501,7 +501,6 @@ extern int pgBackupCompareId(const void *f1, const void *f2);
|
||||
extern int pgBackupCompareIdDesc(const void *f1, const void *f2);
|
||||
extern int pgBackupCompareIdEqual(const void *l, const void *r);
|
||||
|
||||
extern pgBackup* find_direct_child(parray *backup_list, pgBackup *target_backup);
|
||||
extern pgBackup* find_parent_full_backup(pgBackup *current_backup);
|
||||
extern int scan_parent_chain(pgBackup *current_backup, pgBackup **result_backup);
|
||||
extern bool is_parent(time_t parent_backup_time, pgBackup *child_backup, bool inclusive);
|
||||
|
Loading…
x
Reference in New Issue
Block a user