Skip to content

Commit df07a52

Browse files
committed
Merge branch 'REL_2_5' into REL_2_6
2 parents 4fb310b + 71f8ccf commit df07a52

File tree

12 files changed

+186
-223
lines changed

12 files changed

+186
-223
lines changed

src/backup.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
183183
elog(ERROR, "pg_probackup binary version is %s, but backup %s version is %s. "
184184
"pg_probackup do not guarantee to be forward compatible. "
185185
"Please upgrade pg_probackup binary.",
186-
PROGRAM_VERSION, base36enc(prev_backup->start_time), prev_backup->program_version);
186+
PROGRAM_VERSION, backup_id_of(prev_backup), prev_backup->program_version);
187187

188-
elog(INFO, "Parent backup: %s", base36enc(prev_backup->start_time));
188+
elog(INFO, "Parent backup: %s", backup_id_of(prev_backup));
189189

190190
/* Files of previous backup needed by DELTA backup */
191191
prev_backup_filelist = get_backup_filelist(prev_backup, true);
@@ -226,7 +226,7 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
226226
"It may indicate that we are trying to backup PostgreSQL instance from the past.",
227227
(uint32) (current.start_lsn >> 32), (uint32) (current.start_lsn),
228228
(uint32) (prev_backup->start_lsn >> 32), (uint32) (prev_backup->start_lsn),
229-
base36enc(prev_backup->start_time));
229+
backup_id_of(prev_backup));
230230

231231
/* Update running backup meta with START LSN */
232232
write_backup(&current, true);
@@ -603,7 +603,7 @@ do_backup_pg(InstanceState *instanceState, PGconn *backup_conn,
603603
"It may indicate that we are trying to backup PostgreSQL instance from the past.",
604604
(uint32) (current.stop_lsn >> 32), (uint32) (current.stop_lsn),
605605
(uint32) (prev_backup->stop_lsn >> 32), (uint32) (prev_backup->stop_lsn),
606-
base36enc(prev_backup->stop_lsn));
606+
backup_id_of(prev_backup));
607607

608608
/* clean external directories list */
609609
if (external_dirs)
@@ -734,7 +734,7 @@ do_backup(InstanceState *instanceState, pgSetBackupParams *set_backup_params,
734734
/* don't care about freeing base36enc_dup memory, we exit anyway */
735735
elog(ERROR, "Can't assign backup_id from requested start_time (%s), "
736736
"this time must be later that backup %s",
737-
base36enc_dup(start_time), base36enc_dup(latest_backup_id));
737+
base36enc(start_time), base36enc(latest_backup_id));
738738

739739
current.backup_id = start_time;
740740
pgBackupInitDir(&current, instanceState->instance_backup_subdir_path);

src/catalog.c

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ write_backup_status(pgBackup *backup, BackupStatus status,
152152

153153
/* lock backup in exclusive mode */
154154
if (!lock_backup(tmp, strict, true))
155-
elog(ERROR, "Cannot lock backup %s directory", base36enc(backup->start_time));
155+
elog(ERROR, "Cannot lock backup %s directory", backup_id_of(backup));
156156

157157
write_backup(tmp, strict);
158158

@@ -192,7 +192,7 @@ lock_backup(pgBackup *backup, bool strict, bool exclusive)
192192

193193
join_path_components(lock_file, backup->root_dir, BACKUP_LOCK_FILE);
194194

195-
rc = grab_excl_lock_file(backup->root_dir, base36enc(backup->start_time), strict);
195+
rc = grab_excl_lock_file(backup->root_dir, backup_id_of(backup), strict);
196196

197197
if (rc == LOCK_FAIL_TIMEOUT)
198198
return false;
@@ -257,7 +257,7 @@ lock_backup(pgBackup *backup, bool strict, bool exclusive)
257257
* freed some space on filesystem, thanks to unlinking of BACKUP_RO_LOCK_FILE.
258258
* If somebody concurrently acquired exclusive lock file first, then we should give up.
259259
*/
260-
if (grab_excl_lock_file(backup->root_dir, base36enc(backup->start_time), strict) == LOCK_FAIL_TIMEOUT)
260+
if (grab_excl_lock_file(backup->root_dir, backup_id_of(backup), strict) == LOCK_FAIL_TIMEOUT)
261261
return false;
262262

263263
return true;
@@ -523,7 +523,7 @@ grab_excl_lock_file(const char *root_dir, const char *backup_id, bool strict)
523523
}
524524

525525
// elog(LOG, "Acquired exclusive lock for backup %s after %ds",
526-
// base36enc(backup->start_time),
526+
// backup_id_of(backup),
527527
// LOCK_TIMEOUT - ntries + LOCK_STALE_TIMEOUT - empty_tries);
528528

529529
return LOCK_OK;
@@ -563,7 +563,7 @@ wait_shared_owners(pgBackup *backup)
563563
{
564564
if (interrupted)
565565
elog(ERROR, "Interrupted while locking backup %s",
566-
base36enc(backup->start_time));
566+
backup_id_of(backup));
567567

568568
if (encoded_pid == my_pid)
569569
break;
@@ -575,10 +575,10 @@ wait_shared_owners(pgBackup *backup)
575575
if ((ntries % LOG_FREQ) == 0)
576576
{
577577
elog(WARNING, "Process %lld is using backup %s in shared mode, and is still running",
578-
(long long)encoded_pid, base36enc(backup->start_time));
578+
(long long)encoded_pid, backup_id_of(backup));
579579

580580
elog(WARNING, "Waiting %u seconds on lock for backup %s", ntries,
581-
base36enc(backup->start_time));
581+
backup_id_of(backup));
582582
}
583583

584584
sleep(1);
@@ -606,7 +606,7 @@ wait_shared_owners(pgBackup *backup)
606606
if (ntries <= 0)
607607
{
608608
elog(WARNING, "Cannot to lock backup %s in exclusive mode, because process %llu owns shared lock",
609-
base36enc(backup->start_time), (long long)encoded_pid);
609+
backup_id_of(backup), (long long)encoded_pid);
610610
return 1;
611611
}
612612

@@ -979,15 +979,15 @@ catalog_get_backup_list(InstanceState *instanceState, time_t requested_backup_id
979979

980980
if (!backup)
981981
{
982-
backup = pgut_new(pgBackup);
982+
backup = pgut_new0(pgBackup);
983983
pgBackupInit(backup);
984984
backup->start_time = base36dec(data_ent->d_name);
985985
}
986-
else if (strcmp(base36enc(backup->start_time), data_ent->d_name) != 0)
986+
else if (strcmp(backup_id_of(backup), data_ent->d_name) != 0)
987987
{
988988
/* TODO there is no such guarantees */
989989
elog(WARNING, "backup ID in control file \"%s\" doesn't match name of the backup folder \"%s\"",
990-
base36enc(backup->start_time), backup_conf_path);
990+
backup_id_of(backup), backup_conf_path);
991991
}
992992

993993
backup->root_dir = pgut_strdup(data_path);
@@ -1026,7 +1026,7 @@ catalog_get_backup_list(InstanceState *instanceState, time_t requested_backup_id
10261026
{
10271027
pgBackup *curr = parray_get(backups, i);
10281028
pgBackup **ancestor;
1029-
pgBackup key;
1029+
pgBackup key = {0};
10301030

10311031
if (curr->backup_mode == BACKUP_MODE_FULL)
10321032
continue;
@@ -1202,7 +1202,7 @@ get_backup_filelist(pgBackup *backup, bool strict)
12021202

12031203
/* redundant sanity? */
12041204
if (!files)
1205-
elog(strict ? ERROR : WARNING, "Failed to get file list for backup %s", base36enc(backup->start_time));
1205+
elog(strict ? ERROR : WARNING, "Failed to get file list for backup %s", backup_id_of(backup));
12061206

12071207
return files;
12081208
}
@@ -1228,7 +1228,7 @@ catalog_lock_backup_list(parray *backup_list, int from_idx, int to_idx, bool str
12281228
pgBackup *backup = (pgBackup *) parray_get(backup_list, i);
12291229
if (!lock_backup(backup, strict, exclusive))
12301230
elog(ERROR, "Cannot lock backup %s directory",
1231-
base36enc(backup->start_time));
1231+
backup_id_of(backup));
12321232
}
12331233
}
12341234

@@ -1241,7 +1241,6 @@ catalog_get_last_data_backup(parray *backup_list, TimeLineID tli, time_t current
12411241
int i;
12421242
pgBackup *full_backup = NULL;
12431243
pgBackup *tmp_backup = NULL;
1244-
char *invalid_backup_id;
12451244

12461245
/* backup_list is sorted in order of descending ID */
12471246
for (i = 0; i < parray_num(backup_list); i++)
@@ -1262,7 +1261,7 @@ catalog_get_last_data_backup(parray *backup_list, TimeLineID tli, time_t current
12621261
return NULL;
12631262

12641263
elog(LOG, "Latest valid FULL backup: %s",
1265-
base36enc(full_backup->start_time));
1264+
backup_id_of(full_backup));
12661265

12671266
/* FULL backup is found, lets find his latest child */
12681267
for (i = 0; i < parray_num(backup_list); i++)
@@ -1277,20 +1276,14 @@ catalog_get_last_data_backup(parray *backup_list, TimeLineID tli, time_t current
12771276
{
12781277
/* broken chain */
12791278
case ChainIsBroken:
1280-
invalid_backup_id = base36enc_dup(tmp_backup->parent_backup);
1281-
12821279
elog(WARNING, "Backup %s has missing parent: %s. Cannot be a parent",
1283-
base36enc(backup->start_time), invalid_backup_id);
1284-
pg_free(invalid_backup_id);
1280+
backup_id_of(backup), base36enc(tmp_backup->parent_backup));
12851281
continue;
12861282

12871283
/* chain is intact, but at least one parent is invalid */
12881284
case ChainIsInvalid:
1289-
invalid_backup_id = base36enc_dup(tmp_backup->start_time);
1290-
12911285
elog(WARNING, "Backup %s has invalid parent: %s. Cannot be a parent",
1292-
base36enc(backup->start_time), invalid_backup_id);
1293-
pg_free(invalid_backup_id);
1286+
backup_id_of(backup), backup_id_of(tmp_backup));
12941287
continue;
12951288

12961289
/* chain is ok */
@@ -1309,7 +1302,7 @@ catalog_get_last_data_backup(parray *backup_list, TimeLineID tli, time_t current
13091302
else
13101303
{
13111304
elog(WARNING, "Backup %s has status: %s. Cannot be a parent.",
1312-
base36enc(backup->start_time), status2str(backup->status));
1305+
backup_id_of(backup), status2str(backup->status));
13131306
}
13141307
}
13151308

@@ -1395,7 +1388,7 @@ get_multi_timeline_parent(parray *backup_list, parray *tli_list,
13951388
return NULL;
13961389
else
13971390
elog(LOG, "Latest valid full backup: %s, tli: %i",
1398-
base36enc(ancestor_backup->start_time), ancestor_backup->tli);
1391+
backup_id_of(ancestor_backup), ancestor_backup->tli);
13991392

14001393
/* At this point we found suitable full backup,
14011394
* now we must find his latest child, suitable to be
@@ -1908,7 +1901,7 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
19081901
{
19091902
elog(LOG, "Pinned backup %s is ignored for the "
19101903
"purpose of WAL retention",
1911-
base36enc(backup->start_time));
1904+
backup_id_of(backup));
19121905
continue;
19131906
}
19141907

@@ -2094,7 +2087,7 @@ catalog_get_timelines(InstanceState *instanceState, InstanceConfig *instance)
20942087
elog(LOG, "Archive backup %s to stay consistent "
20952088
"protect from purge WAL interval "
20962089
"between %s and %s on timeline %i",
2097-
base36enc(backup->start_time),
2090+
backup_id_of(backup),
20982091
begin_segno_str, end_segno_str, backup->tli);
20992092

21002093
if (tlinfo->keep_segments == NULL)
@@ -2303,7 +2296,7 @@ pin_backup(pgBackup *target_backup, pgSetBackupParams *set_backup_params)
23032296
if (target_backup->expire_time == 0)
23042297
{
23052298
elog(WARNING, "Backup %s is not pinned, nothing to unpin",
2306-
base36enc(target_backup->start_time));
2299+
backup_id_of(target_backup));
23072300
return;
23082301
}
23092302
target_backup->expire_time = 0;
@@ -2323,11 +2316,11 @@ pin_backup(pgBackup *target_backup, pgSetBackupParams *set_backup_params)
23232316
char expire_timestamp[100];
23242317

23252318
time2iso(expire_timestamp, lengthof(expire_timestamp), target_backup->expire_time, false);
2326-
elog(INFO, "Backup %s is pinned until '%s'", base36enc(target_backup->start_time),
2319+
elog(INFO, "Backup %s is pinned until '%s'", backup_id_of(target_backup),
23272320
expire_timestamp);
23282321
}
23292322
else
2330-
elog(INFO, "Backup %s is unpinned", base36enc(target_backup->start_time));
2323+
elog(INFO, "Backup %s is unpinned", backup_id_of(target_backup));
23312324

23322325
return;
23332326
}
@@ -2347,7 +2340,7 @@ add_note(pgBackup *target_backup, char *note)
23472340
{
23482341
target_backup->note = NULL;
23492342
elog(INFO, "Removing note from backup %s",
2350-
base36enc(target_backup->start_time));
2343+
backup_id_of(target_backup));
23512344
}
23522345
else
23532346
{
@@ -2362,7 +2355,7 @@ add_note(pgBackup *target_backup, char *note)
23622355

23632356
target_backup->note = note_string;
23642357
elog(INFO, "Adding note to backup %s: '%s'",
2365-
base36enc(target_backup->start_time), target_backup->note);
2358+
backup_id_of(target_backup), target_backup->note);
23662359
}
23672360

23682361
/* Update backup.control */
@@ -2684,7 +2677,7 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
26842677
static pgBackup *
26852678
readBackupControlFile(const char *path)
26862679
{
2687-
pgBackup *backup = pgut_new(pgBackup);
2680+
pgBackup *backup = pgut_new0(pgBackup);
26882681
char *backup_mode = NULL;
26892682
char *start_lsn = NULL;
26902683
char *stop_lsn = NULL;
@@ -3094,7 +3087,7 @@ find_parent_full_backup(pgBackup *current_backup)
30943087
base36enc(base_full_backup->parent_backup));
30953088
else
30963089
elog(WARNING, "Failed to find parent FULL backup for %s",
3097-
base36enc(current_backup->start_time));
3090+
backup_id_of(current_backup));
30983091
return NULL;
30993092
}
31003093

src/data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ restore_non_data_file(parray *parent_chain, pgBackup *dest_backup,
12981298
if (!tmp_file)
12991299
{
13001300
elog(ERROR, "Failed to locate non-data file \"%s\" in backup %s",
1301-
dest_file->rel_path, base36enc(tmp_backup->start_time));
1301+
dest_file->rel_path, backup_id_of(tmp_backup));
13021302
continue;
13031303
}
13041304

@@ -1331,7 +1331,7 @@ restore_non_data_file(parray *parent_chain, pgBackup *dest_backup,
13311331
if (tmp_file->write_size <= 0)
13321332
elog(ERROR, "Full copy of non-data file has invalid size: %lli. "
13331333
"Metadata corruption in backup %s in file: \"%s\"",
1334-
(long long)tmp_file->write_size, base36enc(tmp_backup->start_time),
1334+
(long long)tmp_file->write_size, backup_id_of(tmp_backup),
13351335
to_fullpath);
13361336

13371337
/* incremental restore */

0 commit comments

Comments
 (0)