You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Add manifest flags for file processing during backup.
The prior method was to check a combination of fields to determine if a file needed to be copied, delta'd, or resumed. This was complicated and ultimately imposed a limitation on the number of operations that could be performed. Introduce copy, delta, and resume flags in the manifest to make it clearer which operations need to be performed and to reduce complex and duplicated logic. This also allows zero-length bundled files to be completed during manifest build rather than later on during backup processing.
This commit is contained in:
@ -864,7 +864,7 @@ testRun(void)
|
||||
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, false, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, cipherTypeNone, NULL, fileList), 0),
|
||||
"pg file missing, ignoreMissing=true, no delta");
|
||||
TEST_RESULT_UINT(result.copySize + result.repoSize, 0, "copy/repo size 0");
|
||||
TEST_RESULT_UINT(result.backupCopyResult, backupCopyResultSkip, "skip file");
|
||||
@ -889,7 +889,7 @@ testRun(void)
|
||||
lstAdd(fileList, &file);
|
||||
|
||||
TEST_ERROR(
|
||||
backupFile(repoFile, compressTypeNone, 1, false, cipherTypeNone, NULL, fileList), FileMissingError,
|
||||
backupFile(repoFile, compressTypeNone, 1, cipherTypeNone, NULL, fileList), FileMissingError,
|
||||
"unable to open missing file '" TEST_PATH "/pg/missing' for read");
|
||||
|
||||
// Create a pg file to backup
|
||||
@ -925,7 +925,7 @@ testRun(void)
|
||||
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, false, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, cipherTypeNone, NULL, fileList), 0),
|
||||
"file checksummed with pageChecksum enabled");
|
||||
TEST_RESULT_UINT(result.copySize, 9, "copy=pgFile size");
|
||||
TEST_RESULT_UINT(result.repoSize, 9, "repo=pgFile size");
|
||||
@ -955,7 +955,7 @@ testRun(void)
|
||||
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, false, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, cipherTypeNone, NULL, fileList), 0),
|
||||
"backup file");
|
||||
TEST_RESULT_UINT(result.copySize, 12, "copy size");
|
||||
TEST_RESULT_UINT(result.repoSize, 12, "repo size");
|
||||
@ -972,6 +972,7 @@ testRun(void)
|
||||
file = (BackupFile)
|
||||
{
|
||||
.pgFile = pgFile,
|
||||
.pgFileDelta = true,
|
||||
.pgFileIgnoreMissing = false,
|
||||
.pgFileSize = 9,
|
||||
.pgFileCopyExactSize = true,
|
||||
@ -986,7 +987,7 @@ testRun(void)
|
||||
// File exists in repo and db, pg checksum match, delta set, ignoreMissing false, hasReference - NOOP
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, true, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, cipherTypeNone, NULL, fileList), 0),
|
||||
"file in db and repo, checksum equal, no ignoreMissing, no pageChecksum, delta, hasReference");
|
||||
TEST_RESULT_UINT(result.copySize, 9, "copy size set");
|
||||
TEST_RESULT_UINT(result.repoSize, 0, "repo size not set since already exists in repo");
|
||||
@ -1003,6 +1004,7 @@ testRun(void)
|
||||
file = (BackupFile)
|
||||
{
|
||||
.pgFile = pgFile,
|
||||
.pgFileDelta = true,
|
||||
.pgFileIgnoreMissing = false,
|
||||
.pgFileSize = 9,
|
||||
.pgFileCopyExactSize = true,
|
||||
@ -1017,7 +1019,7 @@ testRun(void)
|
||||
// File exists in repo and db, pg checksum mismatch, delta set, ignoreMissing false, hasReference - COPY
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, true, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, cipherTypeNone, NULL, fileList), 0),
|
||||
"file in db and repo, pg checksum not equal, no ignoreMissing, no pageChecksum, delta, hasReference");
|
||||
TEST_RESULT_UINT(result.copySize, 9, "copy 9 bytes");
|
||||
TEST_RESULT_UINT(result.repoSize, 9, "repo=copy size");
|
||||
@ -1034,6 +1036,7 @@ testRun(void)
|
||||
file = (BackupFile)
|
||||
{
|
||||
.pgFile = pgFile,
|
||||
.pgFileDelta = true,
|
||||
.pgFileIgnoreMissing = false,
|
||||
.pgFileSize = 9999999,
|
||||
.pgFileCopyExactSize = true,
|
||||
@ -1048,7 +1051,7 @@ testRun(void)
|
||||
// File exists in repo and pg, pg checksum same, pg size passed is different, delta set, ignoreMissing false, hasReference
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, true, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, cipherTypeNone, NULL, fileList), 0),
|
||||
"db & repo file, pg checksum same, pg size different, no ignoreMissing, no pageChecksum, delta, hasReference");
|
||||
TEST_RESULT_UINT(result.copySize, 12, "copy=pgFile size");
|
||||
TEST_RESULT_UINT(result.repoSize, 12, "repo=pgFile size");
|
||||
@ -1065,12 +1068,14 @@ testRun(void)
|
||||
file = (BackupFile)
|
||||
{
|
||||
.pgFile = pgFile,
|
||||
.pgFileDelta = true,
|
||||
.pgFileIgnoreMissing = false,
|
||||
.pgFileSize = 9,
|
||||
.pgFileCopyExactSize = true,
|
||||
.pgFileChecksum = STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"),
|
||||
.pgFileChecksumPage = false,
|
||||
.manifestFile = STRDEF(BOGUS_STR),
|
||||
.manifestFileResume = true,
|
||||
.manifestFileHasReference = false,
|
||||
};
|
||||
|
||||
@ -1082,7 +1087,7 @@ testRun(void)
|
||||
storageRepo(), STORAGE_REPO_BACKUP "/20190718-155825F", "testfile\n", .comment = "resumed file is missing in repo");
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, true, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, cipherTypeNone, NULL, fileList), 0),
|
||||
"backup 9 bytes of pgfile to file to resume in repo");
|
||||
TEST_RESULT_UINT(result.copySize, 9, "copy 9 bytes");
|
||||
TEST_RESULT_UINT(result.repoSize, 9, "repo=copy size");
|
||||
@ -1106,12 +1111,14 @@ testRun(void)
|
||||
file = (BackupFile)
|
||||
{
|
||||
.pgFile = pgFile,
|
||||
.pgFileDelta = true,
|
||||
.pgFileIgnoreMissing = false,
|
||||
.pgFileSize = 9,
|
||||
.pgFileCopyExactSize = true,
|
||||
.pgFileChecksum = STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"),
|
||||
.pgFileChecksumPage = false,
|
||||
.manifestFile = pgFile,
|
||||
.manifestFileResume = true,
|
||||
.manifestFileHasReference = false,
|
||||
};
|
||||
|
||||
@ -1122,7 +1129,7 @@ testRun(void)
|
||||
// Delta set, ignoreMissing false, no hasReference
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, true, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, cipherTypeNone, NULL, fileList), 0),
|
||||
"db & repo file, pgFileMatch, repo checksum no match, no ignoreMissing, no pageChecksum, delta, no hasReference");
|
||||
TEST_RESULT_UINT(result.copySize, 9, "copy 9 bytes");
|
||||
TEST_RESULT_UINT(result.repoSize, 9, "repo=copy size");
|
||||
@ -1139,12 +1146,14 @@ testRun(void)
|
||||
file = (BackupFile)
|
||||
{
|
||||
.pgFile = missingFile,
|
||||
.pgFileDelta = true,
|
||||
.pgFileIgnoreMissing = true,
|
||||
.pgFileSize = 9,
|
||||
.pgFileCopyExactSize = true,
|
||||
.pgFileChecksum = STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"),
|
||||
.pgFileChecksumPage = false,
|
||||
.manifestFile = pgFile,
|
||||
.manifestFileResume = true,
|
||||
.manifestFileHasReference = false,
|
||||
};
|
||||
|
||||
@ -1152,7 +1161,7 @@ testRun(void)
|
||||
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, true, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, cipherTypeNone, NULL, fileList), 0),
|
||||
"file in repo only, checksum in repo equal, ignoreMissing=true, no pageChecksum, delta, no hasReference");
|
||||
TEST_RESULT_UINT(result.copySize + result.repoSize, 0, "copy=repo=0 size");
|
||||
TEST_RESULT_UINT(result.backupCopyResult, backupCopyResultSkip, "skip file");
|
||||
@ -1184,7 +1193,7 @@ testRun(void)
|
||||
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeGz, 3, false, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeGz, 3, cipherTypeNone, NULL, fileList), 0),
|
||||
"pg file exists, no checksum, no ignoreMissing, compression, no pageChecksum, no delta, no hasReference");
|
||||
TEST_RESULT_UINT(result.copySize, 9, "copy=pgFile size");
|
||||
TEST_RESULT_UINT(result.repoSize, 29, "repo compress size");
|
||||
@ -1209,6 +1218,7 @@ testRun(void)
|
||||
.pgFileChecksum = STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"),
|
||||
.pgFileChecksumPage = false,
|
||||
.manifestFile = pgFile,
|
||||
.manifestFileResume = true,
|
||||
.manifestFileHasReference = false,
|
||||
};
|
||||
|
||||
@ -1216,7 +1226,7 @@ testRun(void)
|
||||
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeGz, 3, false, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeGz, 3, cipherTypeNone, NULL, fileList), 0),
|
||||
"pg file & repo exists, match, checksum, no ignoreMissing, compression, no pageChecksum, no delta, no hasReference");
|
||||
TEST_RESULT_UINT(result.copySize, 9, "copy=pgFile size");
|
||||
TEST_RESULT_UINT(result.repoSize, 0, "repo size not calculated");
|
||||
@ -1253,7 +1263,7 @@ testRun(void)
|
||||
// No prior checksum, no compression, no pageChecksum, no delta, no hasReference
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, false, cipherTypeNone, NULL, fileList), 0),
|
||||
*(BackupFileResult *)lstGet(backupFile(repoFile, compressTypeNone, 1, cipherTypeNone, NULL, fileList), 0),
|
||||
"zero-sized pg file exists, no repo file, no ignoreMissing, no pageChecksum, no delta, no hasReference");
|
||||
TEST_RESULT_UINT(result.copySize + result.repoSize, 0, "copy=repo=pgFile size 0");
|
||||
TEST_RESULT_UINT(result.backupCopyResult, backupCopyResultCopy, "copy file");
|
||||
@ -1305,7 +1315,7 @@ testRun(void)
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(
|
||||
backupFile(repoFile, compressTypeNone, 1, false, cipherTypeAes256Cbc, STRDEF(TEST_CIPHER_PASS), fileList), 0),
|
||||
backupFile(repoFile, compressTypeNone, 1, cipherTypeAes256Cbc, STRDEF(TEST_CIPHER_PASS), fileList), 0),
|
||||
"pg file exists, no repo file, no ignoreMissing, no pageChecksum, no delta, no hasReference");
|
||||
TEST_RESULT_UINT(result.copySize, 9, "copy size set");
|
||||
TEST_RESULT_UINT(result.repoSize, 32, "repo size set");
|
||||
@ -1324,12 +1334,14 @@ testRun(void)
|
||||
file = (BackupFile)
|
||||
{
|
||||
.pgFile = pgFile,
|
||||
.pgFileDelta = true,
|
||||
.pgFileIgnoreMissing = false,
|
||||
.pgFileSize = 8,
|
||||
.pgFileCopyExactSize = true,
|
||||
.pgFileChecksum = STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"),
|
||||
.pgFileChecksumPage = false,
|
||||
.manifestFile = pgFile,
|
||||
.manifestFileResume = true,
|
||||
.manifestFileHasReference = false,
|
||||
};
|
||||
|
||||
@ -1339,7 +1351,7 @@ testRun(void)
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(
|
||||
backupFile(repoFile, compressTypeNone, 1, true, cipherTypeAes256Cbc, STRDEF(TEST_CIPHER_PASS), fileList), 0),
|
||||
backupFile(repoFile, compressTypeNone, 1, cipherTypeAes256Cbc, STRDEF(TEST_CIPHER_PASS), fileList), 0),
|
||||
"pg and repo file exists, pgFileMatch false, no ignoreMissing, no pageChecksum, delta, no hasReference");
|
||||
TEST_RESULT_UINT(result.copySize, 8, "copy size set");
|
||||
TEST_RESULT_UINT(result.repoSize, 32, "repo size set");
|
||||
@ -1364,6 +1376,7 @@ testRun(void)
|
||||
.pgFileChecksum = STRDEF("9bc8ab2dda60ef4beed07d1e19ce0676d5edde67"),
|
||||
.pgFileChecksumPage = false,
|
||||
.manifestFile = pgFile,
|
||||
.manifestFileResume = true,
|
||||
.manifestFileHasReference = false,
|
||||
};
|
||||
|
||||
@ -1372,7 +1385,7 @@ testRun(void)
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(
|
||||
backupFile(repoFile, compressTypeNone, 0, false, cipherTypeAes256Cbc, STRDEF(TEST_CIPHER_PASS), fileList), 0),
|
||||
backupFile(repoFile, compressTypeNone, 0, cipherTypeAes256Cbc, STRDEF(TEST_CIPHER_PASS), fileList), 0),
|
||||
"pg and repo file exists, checksum mismatch, no ignoreMissing, no pageChecksum, no delta, no hasReference");
|
||||
TEST_RESULT_UINT(result.copySize, 9, "copy size set");
|
||||
TEST_RESULT_UINT(result.repoSize, 32, "repo size set");
|
||||
@ -1397,6 +1410,7 @@ testRun(void)
|
||||
.pgFileChecksum = STRDEF("1234567890123456789012345678901234567890"),
|
||||
.pgFileChecksumPage = false,
|
||||
.manifestFile = pgFile,
|
||||
.manifestFileResume = true,
|
||||
.manifestFileHasReference = false,
|
||||
};
|
||||
|
||||
@ -1405,7 +1419,7 @@ testRun(void)
|
||||
TEST_ASSIGN(
|
||||
result,
|
||||
*(BackupFileResult *)lstGet(
|
||||
backupFile(repoFile, compressTypeNone, 0, false, cipherTypeAes256Cbc, STRDEF(TEST_CIPHER_PASS), fileList), 0),
|
||||
backupFile(repoFile, compressTypeNone, 0, cipherTypeAes256Cbc, STRDEF(TEST_CIPHER_PASS), fileList), 0),
|
||||
"backup file");
|
||||
|
||||
TEST_RESULT_UINT(result.copySize, 9, "copy size set");
|
||||
|
Reference in New Issue
Block a user