mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-11-28 09:33:54 +02:00
base36enc(backup->backup_id) -> backup_id_of(backup)
Here we assume backup_id == start_time. It is really so at the moment, but could change in future. Well, it almost always same. Sometime backup_id is set while start_time is not set yet (backup creation). And we had to fix places where start_time were changed without change of backup_id.
This commit is contained in:
parent
44fef8894e
commit
87dd3f2021
@ -768,6 +768,7 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
|
||||
|
||||
/* Update backup status and other metainfo. */
|
||||
current.status = BACKUP_STATUS_RUNNING;
|
||||
/* XXX BACKUP_ID change it when backup_id wouldn't match start_time */
|
||||
current.start_time = current.backup_id;
|
||||
|
||||
strlcpy(current.program_version, PROGRAM_VERSION,
|
||||
@ -778,13 +779,13 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
|
||||
|
||||
elog(INFO, "Backup start, pg_probackup version: %s, instance: %s, backup ID: %s, backup mode: %s, "
|
||||
"wal mode: %s, remote: %s, compress-algorithm: %s, compress-level: %i",
|
||||
PROGRAM_VERSION, instanceState->instance_name, base36enc(current.backup_id), pgBackupGetBackupMode(¤t, false),
|
||||
PROGRAM_VERSION, instanceState->instance_name, backup_id_of(¤t), pgBackupGetBackupMode(¤t, false),
|
||||
current.stream ? "STREAM" : "ARCHIVE", IsSshProtocol() ? "true" : "false",
|
||||
deparse_compress_alg(current.compress_alg), current.compress_level);
|
||||
|
||||
if (!lock_backup(¤t, true, true))
|
||||
elog(ERROR, "Cannot lock backup %s directory",
|
||||
base36enc(current.backup_id));
|
||||
backup_id_of(¤t));
|
||||
write_backup(¤t, true);
|
||||
|
||||
/* set the error processing function for the backup process */
|
||||
@ -799,7 +800,7 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
|
||||
backup_conn = pgdata_basic_setup(instance_config.conn_opt, &nodeInfo);
|
||||
|
||||
if (current.from_replica)
|
||||
elog(INFO, "Backup %s is going to be taken from standby", base36enc(current.backup_id));
|
||||
elog(INFO, "Backup %s is going to be taken from standby", backup_id_of(¤t));
|
||||
|
||||
/* TODO, print PostgreSQL full version */
|
||||
//elog(INFO, "PostgreSQL version: %s", nodeInfo.server_version_str);
|
||||
|
@ -275,7 +275,7 @@ lock_backup(pgBackup *backup, bool strict, bool exclusive)
|
||||
|
||||
/* save lock metadata for later unlocking */
|
||||
lock = pgut_malloc(sizeof(LockInfo));
|
||||
snprintf(lock->backup_id, 10, "%s", base36enc(backup->backup_id));
|
||||
snprintf(lock->backup_id, 10, "%s", backup_id_of(backup));
|
||||
snprintf(lock->backup_dir, MAXPGPATH, "%s", backup->root_dir);
|
||||
lock->exclusive = exclusive;
|
||||
|
||||
@ -966,6 +966,9 @@ catalog_get_backup_list(InstanceState *instanceState, time_t requested_backup_id
|
||||
backup = pgut_new0(pgBackup);
|
||||
pgBackupInit(backup);
|
||||
backup->start_time = base36dec(data_ent->d_name);
|
||||
/* XXX BACKUP_ID change it when backup_id wouldn't match start_time */
|
||||
Assert(backup->backup_id == 0 || backup->backup_id == backup->start_time);
|
||||
backup->backup_id = backup->start_time;
|
||||
}
|
||||
else if (strcmp(backup_id_of(backup), data_ent->d_name) != 0)
|
||||
{
|
||||
@ -983,7 +986,6 @@ catalog_get_backup_list(InstanceState *instanceState, time_t requested_backup_id
|
||||
init_header_map(backup);
|
||||
|
||||
/* TODO: save encoded backup id */
|
||||
backup->backup_id = backup->start_time;
|
||||
if (requested_backup_id != INVALID_BACKUP_ID
|
||||
&& requested_backup_id != backup->start_time)
|
||||
{
|
||||
@ -1454,7 +1456,7 @@ pgBackupInitDir(pgBackup *backup, const char *backup_instance_path)
|
||||
if (create_backup_dir(backup, backup_instance_path) != 0)
|
||||
{
|
||||
/* Clear backup_id as indication of error */
|
||||
backup->backup_id = INVALID_BACKUP_ID;
|
||||
reset_backup_id(backup);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1506,7 +1508,7 @@ create_backup_dir(pgBackup *backup, const char *backup_instance_path)
|
||||
int rc;
|
||||
char path[MAXPGPATH];
|
||||
|
||||
join_path_components(path, backup_instance_path, base36enc(backup->backup_id));
|
||||
join_path_components(path, backup_instance_path, backup_id_of(backup));
|
||||
|
||||
/* TODO: add wrapper for remote mode */
|
||||
rc = dir_create_dir(path, DIR_PERMISSION, true);
|
||||
@ -2252,7 +2254,7 @@ pin_backup(pgBackup *target_backup, pgSetBackupParams *set_backup_params)
|
||||
/* sanity, backup must have positive recovery-time */
|
||||
if (target_backup->recovery_time <= 0)
|
||||
elog(ERROR, "Failed to set 'expire-time' for backup %s: invalid 'recovery-time'",
|
||||
base36enc(target_backup->backup_id));
|
||||
backup_id_of(target_backup));
|
||||
|
||||
/* Pin comes from ttl */
|
||||
if (set_backup_params->ttl > 0)
|
||||
@ -2714,6 +2716,9 @@ readBackupControlFile(const char *path)
|
||||
pgBackupFree(backup);
|
||||
return NULL;
|
||||
}
|
||||
/* XXX BACKUP_ID change it when backup_id wouldn't match start_time */
|
||||
Assert(backup->backup_id == 0 || backup->backup_id == backup->start_time);
|
||||
backup->backup_id = backup->start_time;
|
||||
|
||||
if (backup_mode)
|
||||
{
|
||||
|
@ -1115,7 +1115,7 @@ check_tablespace_mapping(pgBackup *backup, bool incremental, bool force, bool pg
|
||||
*/
|
||||
if (tablespace_dirs.head != NULL)
|
||||
elog(ERROR, "Backup %s has no tablespaceses, nothing to remap "
|
||||
"via \"--tablespace-mapping\" option", base36enc(backup->backup_id));
|
||||
"via \"--tablespace-mapping\" option", backup_id_of(backup));
|
||||
return NoTblspc;
|
||||
}
|
||||
|
||||
|
@ -874,6 +874,8 @@ merge_rename:
|
||||
|
||||
full_backup->status = BACKUP_STATUS_OK;
|
||||
full_backup->start_time = full_backup->merge_dest_backup;
|
||||
/* XXX BACKUP_ID change it when backup_id wouldn't match start_time */
|
||||
full_backup->backup_id = full_backup->start_time;
|
||||
full_backup->merge_dest_backup = INVALID_BACKUP_ID;
|
||||
write_backup(full_backup, true);
|
||||
/* Critical section end */
|
||||
|
@ -887,6 +887,7 @@ extern parray *get_dbOid_exclude_list(pgBackup *backup, parray *datname_list,
|
||||
PartialRestoreType partial_restore_type);
|
||||
|
||||
extern const char* backup_id_of(pgBackup *backup);
|
||||
extern void reset_backup_id(pgBackup *backup);
|
||||
|
||||
extern parray *get_backup_filelist(pgBackup *backup, bool strict);
|
||||
extern parray *read_timeline_history(const char *arclog_path, TimeLineID targetTLI, bool strict);
|
||||
|
12
src/util.c
12
src/util.c
@ -565,9 +565,19 @@ datapagemap_print_debug(datapagemap_t *map)
|
||||
const char*
|
||||
backup_id_of(pgBackup *backup)
|
||||
{
|
||||
/* Change this Assert when backup_id will not be bound to start_time */
|
||||
Assert(backup->backup_id == backup->start_time || backup->start_time == 0);
|
||||
|
||||
if (backup->backup_id_encoded[0] == '\x00')
|
||||
{
|
||||
base36enc_to(backup->start_time, backup->backup_id_encoded);
|
||||
base36enc_to(backup->backup_id, backup->backup_id_encoded);
|
||||
}
|
||||
return backup->backup_id_encoded;
|
||||
}
|
||||
|
||||
void
|
||||
reset_backup_id(pgBackup *backup)
|
||||
{
|
||||
backup->backup_id = INVALID_BACKUP_ID;
|
||||
memset(backup->backup_id_encoded, 0, sizeof(backup->backup_id_encoded));
|
||||
}
|
||||
|
@ -734,7 +734,7 @@ validate_tablespace_map(pgBackup *backup, bool no_validate)
|
||||
if (!fileExists(map_path, FIO_BACKUP_HOST))
|
||||
elog(ERROR, "Tablespace map is missing: \"%s\", "
|
||||
"probably backup %s is corrupt, validate it",
|
||||
map_path, base36enc(backup->backup_id));
|
||||
map_path, backup_id_of(backup));
|
||||
|
||||
/* check tablespace map checksumms */
|
||||
if (!no_validate)
|
||||
@ -744,7 +744,7 @@ validate_tablespace_map(pgBackup *backup, bool no_validate)
|
||||
if ((*tablespace_map)->crc != crc)
|
||||
elog(ERROR, "Invalid CRC of tablespace map file \"%s\" : %X. Expected %X, "
|
||||
"probably backup %s is corrupt, validate it",
|
||||
map_path, crc, (*tablespace_map)->crc, base36enc(backup->backup_id));
|
||||
map_path, crc, (*tablespace_map)->crc, backup_id_of(backup));
|
||||
}
|
||||
|
||||
pgFileFree(dummy);
|
||||
|
Loading…
Reference in New Issue
Block a user