1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-18 04:58:51 +02:00

Fix block incremental file names in verify command.

The verify command was not appending the .pgbi extension instead of the compression extension when verifying block incremental files stored outside a bundle.

Originally the idea was that verify would not need any changes (since it just examines repo-size and checksum) but at some point the new extension was added and broke that assumption.

Use backupFileRepoPathP() to generate the correct filename (Just like backup, restore, etc).
This commit is contained in:
David Steele 2023-07-14 17:53:58 +03:00 committed by GitHub
parent 1d42aed152
commit cdb7e26350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 27 deletions

View File

@ -17,6 +17,19 @@
<release date="XXXX-XX-XX" version="2.47dev" title="UNDER DEVELOPMENT"> <release date="XXXX-XX-XX" version="2.47dev" title="UNDER DEVELOPMENT">
<release-core-list> <release-core-list>
<release-bug-list> <release-bug-list>
<release-item>
<github-issue id="2112"/>
<github-pull-request id="2120"/>
<release-item-contributor-list>
<release-item-ideator id="francisco.miguel.biete"/>
<release-item-contributor id="david.steele"/>
<release-item-reviewer id="reid.thompson"/>
</release-item-contributor-list>
<p>Fix block incremental file names in <cmd>verify</cmd> command.</p>
</release-item>
<release-item> <release-item>
<github-issue id="2062"/> <github-issue id="2062"/>
<github-pull-request id="2070"/> <github-pull-request id="2070"/>
@ -12520,7 +12533,7 @@
</contributor> </contributor>
<contributor id="francisco.miguel.biete"> <contributor id="francisco.miguel.biete">
<contributor-name-display>Francisco Miguel Biete</contributor-name-display> <contributor-name-display>Francisco Miguel Biete Banon</contributor-name-display>
<contributor-id type="github">fmbiete</contributor-id> <contributor-id type="github">fmbiete</contributor-id>
</contributor> </contributor>
@ -12529,11 +12542,6 @@
<contributor-id type="github">fvannee</contributor-id> <contributor-id type="github">fvannee</contributor-id>
</contributor> </contributor>
<contributor id="francisco.miguel.biete">
<contributor-name-display>Francisco Miguel Biete</contributor-name-display>
<contributor-id type="github">fmbiete</contributor-id>
</contributor>
<contributor id="vidhya.gurumoorthi"> <contributor id="vidhya.gurumoorthi">
<contributor-name-display>Vidhya Gurumoorthi</contributor-name-display> <contributor-name-display>Vidhya Gurumoorthi</contributor-name-display>
<contributor-id type="github">fpa-postgres</contributor-id> <contributor-id type="github">fpa-postgres</contributor-id>

View File

@ -977,27 +977,21 @@ verifyBackup(VerifyJobData *const jobData)
// Set up the job // Set up the job
ProtocolCommand *command = protocolCommandNew(PROTOCOL_COMMAND_VERIFY_FILE); ProtocolCommand *command = protocolCommandNew(PROTOCOL_COMMAND_VERIFY_FILE);
PackWrite *const param = protocolCommandParam(command); PackWrite *const param = protocolCommandParam(command);
const String *const filePathName = backupFileRepoPathP(
fileBackupLabel, .manifestName = fileData.name, .bundleId = fileData.bundleId,
.compressType = manifestData(jobData->manifest)->backupOptionCompressType,
.blockIncr = fileData.blockIncrMapSize != 0);
const String *const filePathName = strNewFmt( pckWriteStrP(param, filePathName);
STORAGE_REPO_BACKUP "/%s/%s%s", strZ(fileBackupLabel), strZ(fileData.name),
strZ(compressExtStr((manifestData(jobData->manifest))->backupOptionCompressType)));
if (fileData.bundleId != 0) if (fileData.bundleId != 0)
{ {
pckWriteStrP(
param,
strNewFmt(
STORAGE_REPO_BACKUP "/%s/" MANIFEST_PATH_BUNDLE "/%" PRIu64, strZ(fileBackupLabel),
fileData.bundleId));
pckWriteBoolP(param, true); pckWriteBoolP(param, true);
pckWriteU64P(param, fileData.bundleOffset); pckWriteU64P(param, fileData.bundleOffset);
pckWriteU64P(param, fileData.sizeRepo); pckWriteU64P(param, fileData.sizeRepo);
} }
else else
{
pckWriteStrP(param, filePathName);
pckWriteBoolP(param, false); pckWriteBoolP(param, false);
}
// Use the repo checksum when present // Use the repo checksum when present
if (fileData.checksumRepoSha1 != NULL) if (fileData.checksumRepoSha1 != NULL)

View File

@ -1545,6 +1545,8 @@ testRun(void)
"[target:file]\n" "[target:file]\n"
"pg_data/validfile={\"bni\":1,\"bno\":3,\"checksum\":\"%s\",\"size\":%u,\"timestamp\":1565282114}\n" "pg_data/validfile={\"bni\":1,\"bno\":3,\"checksum\":\"%s\",\"size\":%u,\"timestamp\":1565282114}\n"
"pg_data/zerofile={\"size\":0,\"timestamp\":1565282114}\n" "pg_data/zerofile={\"size\":0,\"timestamp\":1565282114}\n"
"pg_data/biind={\"bi\":1,\"bim\":3,\"checksum\":\"9865d483bc5a94f2e30056fc256ed3066af54d04\",\"size\":4"
",\"timestamp\":1565282114}\n"
TEST_MANIFEST_FILE_DEFAULT TEST_MANIFEST_FILE_DEFAULT
TEST_MANIFEST_LINK TEST_MANIFEST_LINK
TEST_MANIFEST_LINK_DEFAULT TEST_MANIFEST_LINK_DEFAULT
@ -1562,6 +1564,8 @@ testRun(void)
HRN_STORAGE_PUT_Z( HRN_STORAGE_PUT_Z(
storageRepoWrite(), STORAGE_REPO_BACKUP "/20201119-163000F/bundle/1", zNewFmt("XXX%s", fileContents), storageRepoWrite(), STORAGE_REPO_BACKUP "/20201119-163000F/bundle/1", zNewFmt("XXX%s", fileContents),
.comment = "valid file"); .comment = "valid file");
HRN_STORAGE_PUT_Z(
storageRepoWrite(), STORAGE_REPO_BACKUP "/20201119-163000F/pg_data/biind.pgbi", "ZZZZ", .comment = "pgbi file");
// Create WAL file with just header info and small WAL size // Create WAL file with just header info and small WAL size
Buffer *walBuffer = bufNew((size_t)(1024 * 1024)); Buffer *walBuffer = bufNew((size_t)(1024 * 1024));
@ -1665,6 +1669,8 @@ testRun(void)
TEST_MANIFEST_TARGET \ TEST_MANIFEST_TARGET \
TEST_MANIFEST_DB \ TEST_MANIFEST_DB \
TEST_MANIFEST_FILE \ TEST_MANIFEST_FILE \
"pg_data/biind={\"bi\":1,\"bim\":3,\"checksum\":\"ffffffffffffffffffffffffffffffffffffffff\",\"size\":4" \
",\"timestamp\":1565282114}\n" \
TEST_MANIFEST_FILE_DEFAULT \ TEST_MANIFEST_FILE_DEFAULT \
TEST_MANIFEST_LINK \ TEST_MANIFEST_LINK \
TEST_MANIFEST_LINK_DEFAULT \ TEST_MANIFEST_LINK_DEFAULT \
@ -1678,6 +1684,8 @@ testRun(void)
HRN_INFO_PUT( HRN_INFO_PUT(
storageRepoWrite(), STORAGE_REPO_BACKUP "/20181119-152900F/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, TEST_MANIFEST_FULL_DB2, storageRepoWrite(), STORAGE_REPO_BACKUP "/20181119-152900F/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, TEST_MANIFEST_FULL_DB2,
.comment = "valid manifest copy - full"); .comment = "valid manifest copy - full");
HRN_STORAGE_PUT_Z(
storageRepoWrite(), STORAGE_REPO_BACKUP "/20181119-152900F/pg_data/biind.pgbi", "ZVZV", .comment = "pgbi file");
// Create valid diff backup // Create valid diff backup
#define TEST_MANIFEST_DIFF_DB2 \ #define TEST_MANIFEST_DIFF_DB2 \
@ -1690,6 +1698,8 @@ testRun(void)
"[target:file]\n" \ "[target:file]\n" \
"pg_data/PG_VERSION={\"checksum\":\"184473f470864e067ee3a22e64b47b0a1c356f29\",\"reference\":\"20181119-152900F\"" \ "pg_data/PG_VERSION={\"checksum\":\"184473f470864e067ee3a22e64b47b0a1c356f29\",\"reference\":\"20181119-152900F\"" \
",\"size\":4,\"timestamp\":1565282114}\n" \ ",\"size\":4,\"timestamp\":1565282114}\n" \
"pg_data/biind={\"bi\":1,\"bim\":3,\"checksum\":\"ffffffffffffffffffffffffffffffffffffffff\"," \
"\"reference\":\"20181119-152900F\",\"size\":4,\"timestamp\":1565282114}\n" \
TEST_MANIFEST_FILE_DEFAULT \ TEST_MANIFEST_FILE_DEFAULT \
TEST_MANIFEST_LINK \ TEST_MANIFEST_LINK \
TEST_MANIFEST_LINK_DEFAULT \ TEST_MANIFEST_LINK_DEFAULT \
@ -1725,22 +1735,20 @@ testRun(void)
"stanza: db\n" "stanza: db\n"
"status: error\n" "status: error\n"
" archiveId: none found\n" " archiveId: none found\n"
" backup: 20181119-152900F, status: invalid, total files checked: 1, total valid files: 0\n" " backup: 20181119-152900F, status: invalid, total files checked: 2, total valid files: 0\n"
" missing: 0, checksum invalid: 1, size invalid: 0, other: 0\n" " missing: 0, checksum invalid: 2, size invalid: 0, other: 0\n"
" backup: 20181119-152900F_20181119-152909D, status: invalid, total files checked: 1, total valid files: 0\n" " backup: 20181119-152900F_20181119-152909D, status: invalid, total files checked: 2, total valid files: 1\n"
" missing: 0, checksum invalid: 1, size invalid: 0, other: 0\n", .remove = true); " missing: 0, checksum invalid: 1, size invalid: 0, other: 0\n", .remove = true);
// The error for the referenced file is logged twice because it is checked again by the second backup since the first backup
// verification had not yet completed before the second backup verification began
TEST_RESULT_LOG( TEST_RESULT_LOG(
"P01 INFO: invalid checksum '20181119-152900F/pg_data/PG_VERSION'\n" "P01 INFO: invalid checksum '20181119-152900F/pg_data/PG_VERSION'\n"
"P01 INFO: invalid checksum '20181119-152900F/pg_data/PG_VERSION'\n" "P01 INFO: invalid checksum '20181119-152900F/pg_data/biind.pgbi'\n"
"P00 INFO: stanza: db\n" "P00 INFO: stanza: db\n"
" status: error\n" " status: error\n"
" archiveId: none found\n" " archiveId: none found\n"
" backup: 20181119-152900F, status: invalid, total files checked: 1, total valid files: 0\n" " backup: 20181119-152900F, status: invalid, total files checked: 2, total valid files: 0\n"
" missing: 0, checksum invalid: 1, size invalid: 0, other: 0\n" " missing: 0, checksum invalid: 2, size invalid: 0, other: 0\n"
" backup: 20181119-152900F_20181119-152909D, status: invalid, total files checked: 1," " backup: 20181119-152900F_20181119-152909D, status: invalid, total files checked: 2,"
" total valid files: 0\n" " total valid files: 1\n"
" missing: 0, checksum invalid: 1, size invalid: 0, other: 0"); " missing: 0, checksum invalid: 1, size invalid: 0, other: 0");
} }