1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-30 05:39:12 +02:00

Refactor backupFile() to remove backupCopyResultReCopy.

Having two enum values for file copy makes things a bit more complicated than they need to be (especially in an upcoming commit).

Instead add a flag to indicate that the repository file was invalid since the only purpose is to trigger a warning message.
This commit is contained in:
David Steele 2023-12-21 15:20:03 -03:00
parent a42614e8f3
commit 701865eca1
4 changed files with 9 additions and 5 deletions

View File

@ -1421,6 +1421,7 @@ backupJobResult(
{ {
ManifestFile file = manifestFileFind(manifest, pckReadStrP(jobResult)); ManifestFile file = manifestFileFind(manifest, pckReadStrP(jobResult));
const BackupCopyResult copyResult = (BackupCopyResult)pckReadU32P(jobResult); const BackupCopyResult copyResult = (BackupCopyResult)pckReadU32P(jobResult);
const bool repoInvalid = pckReadBoolP(jobResult);
const uint64_t copySize = pckReadU64P(jobResult); const uint64_t copySize = pckReadU64P(jobResult);
const uint64_t bundleOffset = pckReadU64P(jobResult); const uint64_t bundleOffset = pckReadU64P(jobResult);
const uint64_t blockIncrMapSize = pckReadU64P(jobResult); const uint64_t blockIncrMapSize = pckReadU64P(jobResult);
@ -1482,8 +1483,10 @@ backupJobResult(
// If the file had to be recopied then warn that there may be an issue with corruption in the repository // If the file had to be recopied then warn that there may be an issue with corruption in the repository
// ??? This should really be below the message below for more context -- can be moved after the migration // ??? This should really be below the message below for more context -- can be moved after the migration
// ??? The name should be a pg path not manifest name -- can be fixed after the migration // ??? The name should be a pg path not manifest name -- can be fixed after the migration
if (copyResult == backupCopyResultReCopy) if (repoInvalid)
{ {
ASSERT(copyResult == backupCopyResultCopy);
LOG_WARN_FMT( LOG_WARN_FMT(
"resumed backup file %s does not have expected checksum %s. The file will be recopied and backup will" "resumed backup file %s does not have expected checksum %s. The file will be recopied and backup will"
" continue but this may be an issue unless the resumed backup path in the repository is known to be" " continue but this may be an issue unless the resumed backup path in the repository is known to be"

View File

@ -168,9 +168,9 @@ backupFile(
} }
MEM_CONTEXT_END(); MEM_CONTEXT_END();
} }
// Else recopy when repo file is not as expected // Else copy when repo file is invalid
else else
fileResult->backupCopyResult = backupCopyResultReCopy; fileResult->repoInvalid = true;
} }
} }
} }
@ -192,7 +192,7 @@ backupFile(
const BackupFile *const file = lstGet(fileList, fileIdx); const BackupFile *const file = lstGet(fileList, fileIdx);
BackupFileResult *const fileResult = lstGet(result, fileIdx); BackupFileResult *const fileResult = lstGet(result, fileIdx);
if (fileResult->backupCopyResult == backupCopyResultCopy || fileResult->backupCopyResult == backupCopyResultReCopy) if (fileResult->backupCopyResult == backupCopyResultCopy)
{ {
// Setup pg file for read. Only read as many bytes as passed in pgFileSize. If the file is growing it does no // Setup pg file for read. Only read as many bytes as passed in pgFileSize. If the file is growing it does no
// good to copy data past the end of the size recorded in the manifest since those blocks will need to be // good to copy data past the end of the size recorded in the manifest since those blocks will need to be

View File

@ -16,7 +16,6 @@ typedef enum
{ {
backupCopyResultChecksum, backupCopyResultChecksum,
backupCopyResultCopy, backupCopyResultCopy,
backupCopyResultReCopy,
backupCopyResultSkip, backupCopyResultSkip,
backupCopyResultNoOp, backupCopyResultNoOp,
backupCopyResultTruncate, backupCopyResultTruncate,
@ -53,6 +52,7 @@ typedef struct BackupFileResult
{ {
const String *manifestFile; // Manifest file const String *manifestFile; // Manifest file
BackupCopyResult backupCopyResult; BackupCopyResult backupCopyResult;
bool repoInvalid; // File was recopied because repo file was invalid
uint64_t copySize; uint64_t copySize;
Buffer *copyChecksum; Buffer *copyChecksum;
Buffer *repoChecksum; // Checksum repo file (including compression, etc.) Buffer *repoChecksum; // Checksum repo file (including compression, etc.)

View File

@ -90,6 +90,7 @@ backupFileProtocol(PackRead *const param, ProtocolServer *const server)
pckWriteStrP(resultPack, fileResult->manifestFile); pckWriteStrP(resultPack, fileResult->manifestFile);
pckWriteU32P(resultPack, fileResult->backupCopyResult); pckWriteU32P(resultPack, fileResult->backupCopyResult);
pckWriteBoolP(resultPack, fileResult->repoInvalid);
pckWriteU64P(resultPack, fileResult->copySize); pckWriteU64P(resultPack, fileResult->copySize);
pckWriteU64P(resultPack, fileResult->bundleOffset); pckWriteU64P(resultPack, fileResult->bundleOffset);
pckWriteU64P(resultPack, fileResult->blockIncrMapSize); pckWriteU64P(resultPack, fileResult->blockIncrMapSize);