Skip to content

Commit d8b8b08

Browse files
committed
[Issue #79]: remove partial validation
1 parent b278a2f commit d8b8b08

File tree

4 files changed

+65
-28
lines changed

4 files changed

+65
-28
lines changed

src/catalog.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,27 @@ catalog_get_backup_list(time_t requested_backup_id)
415415
return NULL;
416416
}
417417

418+
/*
419+
* Create list of backup datafiles.
420+
* If 'requested_backup_id' is INVALID_BACKUP_ID, exit with error.
421+
* If valid backup id is passed only matching backup will be added to the list.
422+
*/
423+
parray *
424+
get_backup_filelist(pgBackup *backup)
425+
{
426+
parray *files = NULL;
427+
char backup_filelist_path[MAXPGPATH];
428+
429+
pgBackupGetPath(backup, backup_filelist_path, lengthof(backup_filelist_path), DATABASE_FILE_LIST);
430+
files = dir_read_file_list(NULL, NULL, backup_filelist_path, FIO_BACKUP_HOST);
431+
432+
/* redundant sanity? */
433+
if (!files)
434+
elog(ERROR, "Failed to get filelist for backup %s", base36enc(backup->start_time));
435+
436+
return files;
437+
}
438+
418439
/*
419440
* Lock list of backups. Function goes in backward direction.
420441
*/

src/pg_probackup.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,10 @@ extern pgRecoveryTarget *parseRecoveryTargetOptions(
521521
const char *target_stop, const char *target_name,
522522
const char *target_action);
523523

524-
extern parray *get_dbOid_exclude_list(pgBackup *backup, parray *files,
525-
parray *datname_list, PartialRestoreType partial_restore_type);
524+
extern parray *get_dbOid_exclude_list(pgBackup *backup, parray *datname_list,
525+
PartialRestoreType partial_restore_type);
526+
527+
extern parray *get_backup_filelist(pgBackup *backup);
526528

527529
/* in merge.c */
528530
extern void do_merge(time_t backup_id);

src/restore.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,9 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
373373
}
374374
}
375375

376+
/* validate datafiles only */
376377
pgBackupValidate(tmp_backup, params);
378+
377379
/* After pgBackupValidate() only following backup
378380
* states are possible: ERROR, RUNNING, CORRUPT and OK.
379381
* Validate WAL only for OK, because there is no point
@@ -390,6 +392,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
390392
}
391393

392394
/* There is no point in wal validation of corrupted backups */
395+
// TODO: there should be a way for a user to request only(!) WAL validation
393396
if (!corrupted_backup)
394397
{
395398
/*
@@ -458,7 +461,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
458461
* throw an error.
459462
*/
460463
if (params->partial_db_list)
461-
dbOid_exclude_list = get_dbOid_exclude_list(dest_backup, dest_files, params->partial_db_list,
464+
dbOid_exclude_list = get_dbOid_exclude_list(dest_backup, params->partial_db_list,
462465
params->partial_restore_type);
463466

464467
/*
@@ -1185,19 +1188,22 @@ parseRecoveryTargetOptions(const char *target_time,
11851188
* we always convert it into exclude_list.
11861189
*/
11871190
parray *
1188-
get_dbOid_exclude_list(pgBackup *backup, parray *files,
1189-
parray *datname_list, PartialRestoreType partial_restore_type)
1191+
get_dbOid_exclude_list(pgBackup *backup, parray *datname_list,
1192+
PartialRestoreType partial_restore_type)
11901193
{
11911194
int i;
11921195
int j;
1193-
parray *database_map = NULL;
1194-
parray *dbOid_exclude_list = NULL;
1195-
pgFile *database_map_file = NULL;
1196-
pg_crc32 crc;
1196+
// pg_crc32 crc;
1197+
parray *database_map = NULL;
1198+
parray *dbOid_exclude_list = NULL;
1199+
pgFile *database_map_file = NULL;
11971200
char path[MAXPGPATH];
11981201
char database_map_path[MAXPGPATH];
1202+
parray *files = NULL;
1203+
1204+
files = get_backup_filelist(backup);
11991205

1200-
/* make sure that database_map is in backup_content.control */
1206+
/* look for 'database_map' file in backup_content.control */
12011207
for (i = 0; i < parray_num(files); i++)
12021208
{
12031209
pgFile *file = (pgFile *) parray_get(files, i);
@@ -1218,11 +1224,11 @@ get_dbOid_exclude_list(pgBackup *backup, parray *files,
12181224
join_path_components(database_map_path, path, DATABASE_MAP);
12191225

12201226
/* check database_map CRC */
1221-
crc = pgFileGetCRC(database_map_path, true, true, NULL, FIO_LOCAL_HOST);
1222-
1223-
if (crc != database_map_file->crc)
1224-
elog(ERROR, "Invalid CRC of backup file \"%s\" : %X. Expected %X",
1225-
database_map_file->path, crc, database_map_file->crc);
1227+
// crc = pgFileGetCRC(database_map_path, true, true, NULL, FIO_LOCAL_HOST);
1228+
//
1229+
// if (crc != database_map_file->crc)
1230+
// elog(ERROR, "Invalid CRC of backup file \"%s\" : %X. Expected %X",
1231+
// database_map_file->path, crc, database_map_file->crc);
12261232

12271233
/* get database_map from file */
12281234
database_map = read_database_map(backup);
@@ -1307,6 +1313,13 @@ get_dbOid_exclude_list(pgBackup *backup, parray *files,
13071313
elog(ERROR, "Failed to find a match in database_map of backup %s for partial restore",
13081314
base36enc(backup->start_time));
13091315

1316+
/* clean backup filelist */
1317+
if (files)
1318+
{
1319+
parray_walk(files, pgFileFree);
1320+
parray_free(files);
1321+
}
1322+
13101323
/* sort dbOid array in ASC order */
13111324
parray_qsort(dbOid_exclude_list, pgCompareOid);
13121325

src/validate.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ typedef struct
4141

4242
/*
4343
* Validate backup files.
44+
* TODO: partial validation.
4445
*/
4546
void
4647
pgBackupValidate(pgBackup *backup, pgRestoreParams *params)
@@ -55,7 +56,7 @@ pgBackupValidate(pgBackup *backup, pgRestoreParams *params)
5556
pthread_t *threads;
5657
validate_files_arg *threads_args;
5758
int i;
58-
parray *dbOid_exclude_list = NULL;
59+
// parray *dbOid_exclude_list = NULL;
5960

6061
/* Check backup version */
6162
if (parse_program_version(backup->program_version) > parse_program_version(PROGRAM_VERSION))
@@ -107,9 +108,9 @@ pgBackupValidate(pgBackup *backup, pgRestoreParams *params)
107108
pgBackupGetPath(backup, path, lengthof(path), DATABASE_FILE_LIST);
108109
files = dir_read_file_list(base_path, external_prefix, path, FIO_BACKUP_HOST);
109110

110-
if (params && params->partial_db_list)
111-
dbOid_exclude_list = get_dbOid_exclude_list(backup, files, params->partial_db_list,
112-
params->partial_restore_type);
111+
// if (params && params->partial_db_list)
112+
// dbOid_exclude_list = get_dbOid_exclude_list(backup, files, params->partial_db_list,
113+
// params->partial_restore_type);
113114

114115
/* setup threads */
115116
for (i = 0; i < parray_num(files); i++)
@@ -136,7 +137,7 @@ pgBackupValidate(pgBackup *backup, pgRestoreParams *params)
136137
arg->stop_lsn = backup->stop_lsn;
137138
arg->checksum_version = backup->checksum_version;
138139
arg->backup_version = parse_program_version(backup->program_version);
139-
arg->dbOid_exclude_list = dbOid_exclude_list;
140+
// arg->dbOid_exclude_list = dbOid_exclude_list;
140141
/* By default there are some error */
141142
threads_args[i].ret = 1;
142143

@@ -204,14 +205,14 @@ pgBackupValidateFiles(void *arg)
204205
* If in partial validate, check if the file belongs to the database
205206
* we exclude. Only files from pgdata can be skipped.
206207
*/
207-
if (arguments->dbOid_exclude_list && file->external_dir_num == 0
208-
&& parray_bsearch(arguments->dbOid_exclude_list,
209-
&file->dbOid, pgCompareOid))
210-
{
211-
elog(VERBOSE, "Skip file validation due to partial restore: \"%s\"",
212-
file->rel_path);
213-
continue;
214-
}
208+
//if (arguments->dbOid_exclude_list && file->external_dir_num == 0
209+
// && parray_bsearch(arguments->dbOid_exclude_list,
210+
// &file->dbOid, pgCompareOid))
211+
//{
212+
// elog(VERBOSE, "Skip file validation due to partial restore: \"%s\"",
213+
// file->rel_path);
214+
// continue;
215+
//}
215216

216217
/*
217218
* Currently we don't compute checksums for

0 commit comments

Comments
 (0)