mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-09 14:45:47 +02:00
[Issue #150] Pinned backups should be ignored for the purpose of WAL retention fulfillment
This commit is contained in:
parent
40003490a3
commit
5f0c024422
@ -988,14 +988,22 @@ catalog_get_timelines(InstanceConfig *instance)
|
|||||||
{
|
{
|
||||||
pgBackup *backup = parray_get(tlinfo->backups, j);
|
pgBackup *backup = parray_get(tlinfo->backups, j);
|
||||||
|
|
||||||
|
/* sanity */
|
||||||
|
if (XLogRecPtrIsInvalid(backup->start_lsn) ||
|
||||||
|
backup->tli <= 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
/* skip invalid backups */
|
/* skip invalid backups */
|
||||||
if (backup->status != BACKUP_STATUS_OK &&
|
if (backup->status != BACKUP_STATUS_OK &&
|
||||||
backup->status != BACKUP_STATUS_DONE)
|
backup->status != BACKUP_STATUS_DONE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* sanity */
|
/*
|
||||||
if (XLogRecPtrIsInvalid(backup->start_lsn) ||
|
* Pinned backups should be ignored for the
|
||||||
backup->tli <= 0)
|
* purpose of retention fulfillment, so skip them.
|
||||||
|
*/
|
||||||
|
if (backup->expire_time > 0 &&
|
||||||
|
backup->expire_time > current_time)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
|
@ -209,7 +209,6 @@ static void
|
|||||||
do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purge_list)
|
do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purge_list)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
time_t current_time;
|
|
||||||
|
|
||||||
parray *redundancy_full_backup_list = NULL;
|
parray *redundancy_full_backup_list = NULL;
|
||||||
|
|
||||||
@ -221,9 +220,6 @@ do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purg
|
|||||||
/* For fancy reporting */
|
/* For fancy reporting */
|
||||||
uint32 actual_window = 0;
|
uint32 actual_window = 0;
|
||||||
|
|
||||||
/* Get current time */
|
|
||||||
current_time = time(NULL);
|
|
||||||
|
|
||||||
/* Calculate n_full_backups and days_threshold */
|
/* Calculate n_full_backups and days_threshold */
|
||||||
if (instance_config.retention_redundancy > 0)
|
if (instance_config.retention_redundancy > 0)
|
||||||
{
|
{
|
||||||
|
@ -92,6 +92,7 @@ static char *target_action = NULL;
|
|||||||
static pgRecoveryTarget *recovery_target_options = NULL;
|
static pgRecoveryTarget *recovery_target_options = NULL;
|
||||||
static pgRestoreParams *restore_params = NULL;
|
static pgRestoreParams *restore_params = NULL;
|
||||||
|
|
||||||
|
time_t current_time = 0;
|
||||||
bool restore_as_replica = false;
|
bool restore_as_replica = false;
|
||||||
bool no_validate = false;
|
bool no_validate = false;
|
||||||
|
|
||||||
@ -267,6 +268,9 @@ main(int argc, char *argv[])
|
|||||||
PROGRAM_NAME = get_progname(argv[0]);
|
PROGRAM_NAME = get_progname(argv[0]);
|
||||||
PROGRAM_FULL_PATH = palloc0(MAXPGPATH);
|
PROGRAM_FULL_PATH = palloc0(MAXPGPATH);
|
||||||
|
|
||||||
|
/* Get current time */
|
||||||
|
current_time = time(NULL);
|
||||||
|
|
||||||
//set_pglocale_pgservice(argv[0], "pgscripts");
|
//set_pglocale_pgservice(argv[0], "pgscripts");
|
||||||
|
|
||||||
#if PG_VERSION_NUM >= 110000
|
#if PG_VERSION_NUM >= 110000
|
||||||
|
@ -282,6 +282,7 @@ typedef struct InstanceConfig
|
|||||||
|
|
||||||
extern ConfigOption instance_options[];
|
extern ConfigOption instance_options[];
|
||||||
extern InstanceConfig instance_config;
|
extern InstanceConfig instance_config;
|
||||||
|
extern time_t current_time;
|
||||||
|
|
||||||
typedef struct PGNodeInfo
|
typedef struct PGNodeInfo
|
||||||
{
|
{
|
||||||
|
@ -1101,10 +1101,8 @@ pg12_recovery_config(pgBackup *backup, bool add_include)
|
|||||||
|
|
||||||
if (add_include)
|
if (add_include)
|
||||||
{
|
{
|
||||||
time_t current_time;
|
|
||||||
char current_time_str[100];
|
char current_time_str[100];
|
||||||
|
|
||||||
current_time = time(NULL);
|
|
||||||
time2iso(current_time_str, lengthof(current_time_str), current_time);
|
time2iso(current_time_str, lengthof(current_time_str), current_time);
|
||||||
|
|
||||||
snprintf(postgres_auto_path, lengthof(postgres_auto_path),
|
snprintf(postgres_auto_path, lengthof(postgres_auto_path),
|
||||||
|
@ -468,7 +468,6 @@ show_instance_plain(const char *instance_name, parray *backup_list, bool show_na
|
|||||||
uint32 widths[SHOW_FIELDS_COUNT];
|
uint32 widths[SHOW_FIELDS_COUNT];
|
||||||
uint32 widths_sum = 0;
|
uint32 widths_sum = 0;
|
||||||
ShowBackendRow *rows;
|
ShowBackendRow *rows;
|
||||||
time_t current_time = time(NULL);
|
|
||||||
TimeLineID parent_tli = 0;
|
TimeLineID parent_tli = 0;
|
||||||
|
|
||||||
for (i = 0; i < SHOW_FIELDS_COUNT; i++)
|
for (i = 0; i < SHOW_FIELDS_COUNT; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user