Skip to content

Commit 8393388

Browse files
committed
Merge branch 'REL_2_5' into REL_2_6
2 parents 3eb238b + 87dd3f2 commit 8393388

File tree

7 files changed

+31
-12
lines changed

7 files changed

+31
-12
lines changed

src/backup.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
767767

768768
/* Update backup status and other metainfo. */
769769
current.status = BACKUP_STATUS_RUNNING;
770+
/* XXX BACKUP_ID change it when backup_id wouldn't match start_time */
770771
current.start_time = current.backup_id;
771772

772773
strlcpy(current.program_version, PROGRAM_VERSION,
@@ -777,13 +778,13 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
777778

778779
elog(INFO, "Backup start, pg_probackup version: %s, instance: %s, backup ID: %s, backup mode: %s, "
779780
"wal mode: %s, remote: %s, compress-algorithm: %s, compress-level: %i",
780-
PROGRAM_VERSION, instanceState->instance_name, base36enc(current.backup_id), pgBackupGetBackupMode(&current, false),
781+
PROGRAM_VERSION, instanceState->instance_name, backup_id_of(&current), pgBackupGetBackupMode(&current, false),
781782
current.stream ? "STREAM" : "ARCHIVE", IsSshProtocol() ? "true" : "false",
782783
deparse_compress_alg(current.compress_alg), current.compress_level);
783784

784785
if (!lock_backup(&current, true, true))
785786
elog(ERROR, "Cannot lock backup %s directory",
786-
base36enc(current.backup_id));
787+
backup_id_of(&current));
787788
write_backup(&current, true);
788789

789790
/* set the error processing function for the backup process */
@@ -798,7 +799,7 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
798799
backup_conn = pgdata_basic_setup(instance_config.conn_opt, &nodeInfo);
799800

800801
if (current.from_replica)
801-
elog(INFO, "Backup %s is going to be taken from standby", base36enc(current.backup_id));
802+
elog(INFO, "Backup %s is going to be taken from standby", backup_id_of(&current));
802803

803804
/* TODO, print PostgreSQL full version */
804805
//elog(INFO, "PostgreSQL version: %s", nodeInfo.server_version_str);

src/catalog.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ lock_backup(pgBackup *backup, bool strict, bool exclusive)
274274

275275
/* save lock metadata for later unlocking */
276276
lock = pgut_malloc(sizeof(LockInfo));
277-
snprintf(lock->backup_id, 10, "%s", base36enc(backup->backup_id));
277+
snprintf(lock->backup_id, 10, "%s", backup_id_of(backup));
278278
snprintf(lock->backup_dir, MAXPGPATH, "%s", backup->root_dir);
279279
lock->exclusive = exclusive;
280280

@@ -982,6 +982,9 @@ catalog_get_backup_list(InstanceState *instanceState, time_t requested_backup_id
982982
backup = pgut_new0(pgBackup);
983983
pgBackupInit(backup);
984984
backup->start_time = base36dec(data_ent->d_name);
985+
/* XXX BACKUP_ID change it when backup_id wouldn't match start_time */
986+
Assert(backup->backup_id == 0 || backup->backup_id == backup->start_time);
987+
backup->backup_id = backup->start_time;
985988
}
986989
else if (strcmp(backup_id_of(backup), data_ent->d_name) != 0)
987990
{
@@ -999,7 +1002,6 @@ catalog_get_backup_list(InstanceState *instanceState, time_t requested_backup_id
9991002
init_header_map(backup);
10001003

10011004
/* TODO: save encoded backup id */
1002-
backup->backup_id = backup->start_time;
10031005
if (requested_backup_id != INVALID_BACKUP_ID
10041006
&& requested_backup_id != backup->start_time)
10051007
{
@@ -1477,7 +1479,7 @@ pgBackupInitDir(pgBackup *backup, const char *backup_instance_path)
14771479
if ($haserr(err))
14781480
{
14791481
/* Clear backup_id as indication of error */
1480-
backup->backup_id = INVALID_BACKUP_ID;
1482+
reset_backup_id(backup);
14811483
return;
14821484
}
14831485

@@ -1534,7 +1536,7 @@ create_backup_dir(pgBackup *backup, const char *backup_instance_path)
15341536
char path[MAXPGPATH];
15351537
err_i err;
15361538

1537-
join_path_components(path, backup_instance_path, base36enc(backup->backup_id));
1539+
join_path_components(path, backup_instance_path, backup_id_of(backup));
15381540

15391541
/* TODO: add wrapper for remote mode */
15401542
err = $i(pioMakeDir, backup->backup_location, .path = path,
@@ -2282,7 +2284,7 @@ pin_backup(pgBackup *target_backup, pgSetBackupParams *set_backup_params)
22822284
/* sanity, backup must have positive recovery-time */
22832285
if (target_backup->recovery_time <= 0)
22842286
elog(ERROR, "Failed to set 'expire-time' for backup %s: invalid 'recovery-time'",
2285-
base36enc(target_backup->backup_id));
2287+
backup_id_of(target_backup));
22862288

22872289
/* Pin comes from ttl */
22882290
if (set_backup_params->ttl > 0)
@@ -2747,6 +2749,9 @@ readBackupControlFile(const char *path)
27472749
pgBackupFree(backup);
27482750
return NULL;
27492751
}
2752+
/* XXX BACKUP_ID change it when backup_id wouldn't match start_time */
2753+
Assert(backup->backup_id == 0 || backup->backup_id == backup->start_time);
2754+
backup->backup_id = backup->start_time;
27502755

27512756
if (backup_mode)
27522757
{

src/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ check_tablespace_mapping(pgBackup *backup, bool incremental, bool force, bool pg
11221122
*/
11231123
if (tablespace_dirs.head != NULL)
11241124
elog(ERROR, "Backup %s has no tablespaceses, nothing to remap "
1125-
"via \"--tablespace-mapping\" option", base36enc(backup->backup_id));
1125+
"via \"--tablespace-mapping\" option", backup_id_of(backup));
11261126
return NoTblspc;
11271127
}
11281128

src/merge.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,8 @@ merge_chain(InstanceState *instanceState,
883883

884884
full_backup->status = BACKUP_STATUS_OK;
885885
full_backup->start_time = full_backup->merge_dest_backup;
886+
/* XXX BACKUP_ID change it when backup_id wouldn't match start_time */
887+
full_backup->backup_id = full_backup->start_time;
886888
full_backup->merge_dest_backup = INVALID_BACKUP_ID;
887889
write_backup(full_backup, true);
888890
/* Critical section end */

src/pg_probackup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ extern parray *get_dbOid_exclude_list(pgBackup *backup, parray *datname_list,
843843
PartialRestoreType partial_restore_type);
844844

845845
extern const char* backup_id_of(pgBackup *backup);
846+
extern void reset_backup_id(pgBackup *backup);
846847

847848
extern parray *get_backup_filelist(pgBackup *backup, bool strict);
848849
extern parray *read_timeline_history(const char *arclog_path, TimeLineID targetTLI, bool strict);

src/util.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,19 @@ datapagemap_print_debug(datapagemap_t *map)
519519
const char*
520520
backup_id_of(pgBackup *backup)
521521
{
522+
/* Change this Assert when backup_id will not be bound to start_time */
523+
Assert(backup->backup_id == backup->start_time || backup->start_time == 0);
524+
522525
if (backup->backup_id_encoded[0] == '\x00')
523526
{
524-
base36enc_to(backup->start_time, backup->backup_id_encoded);
527+
base36enc_to(backup->backup_id, backup->backup_id_encoded);
525528
}
526529
return backup->backup_id_encoded;
527530
}
531+
532+
void
533+
reset_backup_id(pgBackup *backup)
534+
{
535+
backup->backup_id = INVALID_BACKUP_ID;
536+
memset(backup->backup_id_encoded, 0, sizeof(backup->backup_id_encoded));
537+
}

src/validate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ validate_tablespace_map(pgBackup *backup, bool no_validate)
746746
if (!fileExists(map_path, FIO_BACKUP_HOST))
747747
elog(ERROR, "Tablespace map is missing: \"%s\", "
748748
"probably backup %s is corrupt, validate it",
749-
map_path, base36enc(backup->backup_id));
749+
map_path, backup_id_of(backup));
750750

751751
/* check tablespace map checksumms */
752752
if (!no_validate)
@@ -765,7 +765,7 @@ validate_tablespace_map(pgBackup *backup, bool no_validate)
765765
if ((*tablespace_map)->crc != crc)
766766
elog(ERROR, "Invalid CRC of tablespace map file \"%s\" : %X. Expected %X, "
767767
"probably backup %s is corrupt, validate it",
768-
map_path, crc, (*tablespace_map)->crc, base36enc(backup->backup_id));
768+
map_path, crc, (*tablespace_map)->crc, backup_id_of(backup));
769769
}
770770

771771
pgFileFree(dummy);

0 commit comments

Comments
 (0)