mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-04-13 11:30:40 +02:00
Use infoBackupDataByLabel() to log backup size.
Eliminate summing and passing of copied files sizes for logging backup size. Instead, utilize infoBackupDataByLabel() to pull the backup size for the log message.
This commit is contained in:
parent
1a0560d363
commit
a3d7a23a9d
@ -66,6 +66,9 @@
|
||||
<commit subject="Include backup_label and tablespace_map file sizes in log output.">
|
||||
<github-pull-request id="1568"/>
|
||||
</commit>
|
||||
<commit subject="Use infoBackupDataByLabel() to log backup size.">
|
||||
<github-pull-request id="1573"/>
|
||||
</commit>
|
||||
|
||||
<release-item-contributor-list>
|
||||
<release-item-ideator id="mahomed.hussein"/>
|
||||
|
@ -1008,7 +1008,7 @@ typedef struct BackupStopResult
|
||||
} BackupStopResult;
|
||||
|
||||
static BackupStopResult
|
||||
backupStop(BackupData *backupData, Manifest *manifest, uint64_t *backupSizeTotal)
|
||||
backupStop(BackupData *backupData, Manifest *manifest)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelDebug);
|
||||
FUNCTION_LOG_PARAM(BACKUP_DATA, backupData);
|
||||
@ -1039,10 +1039,8 @@ backupStop(BackupData *backupData, Manifest *manifest, uint64_t *backupSizeTotal
|
||||
LOG_INFO_FMT("backup stop archive = %s, lsn = %s", strZ(result.walSegmentName), strZ(result.lsn));
|
||||
|
||||
// Save files returned by stop backup
|
||||
*backupSizeTotal += backupFilePut(
|
||||
backupData, manifest, STRDEF(PG_FILE_BACKUPLABEL), result.timestamp, dbBackupStopResult.backupLabel);
|
||||
*backupSizeTotal += backupFilePut(
|
||||
backupData, manifest, STRDEF(PG_FILE_TABLESPACEMAP), result.timestamp, dbBackupStopResult.tablespaceMap);
|
||||
backupFilePut(backupData, manifest, STRDEF(PG_FILE_BACKUPLABEL), result.timestamp, dbBackupStopResult.backupLabel);
|
||||
backupFilePut(backupData, manifest, STRDEF(PG_FILE_TABLESPACEMAP), result.timestamp, dbBackupStopResult.tablespaceMap);
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
}
|
||||
@ -1153,7 +1151,7 @@ Log the results of a job and throw errors
|
||||
static void
|
||||
backupJobResult(
|
||||
Manifest *manifest, const String *host, const String *const fileName, StringList *fileRemove, ProtocolParallelJob *const job,
|
||||
const uint64_t sizeTotal, uint64_t *sizeProgress, uint64_t *sizeCopied)
|
||||
const uint64_t sizeTotal, uint64_t *sizeProgress)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelDebug);
|
||||
FUNCTION_LOG_PARAM(MANIFEST, manifest);
|
||||
@ -1163,7 +1161,6 @@ backupJobResult(
|
||||
FUNCTION_LOG_PARAM(PROTOCOL_PARALLEL_JOB, job);
|
||||
FUNCTION_LOG_PARAM(UINT64, sizeTotal);
|
||||
FUNCTION_LOG_PARAM_P(UINT64, sizeProgress);
|
||||
FUNCTION_LOG_PARAM_P(UINT64, sizeCopied);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(manifest != NULL);
|
||||
@ -1207,9 +1204,6 @@ backupJobResult(
|
||||
// Else if the repo matched the expect checksum, just log it
|
||||
else if (copyResult == backupCopyResultChecksum)
|
||||
{
|
||||
// Increment size to account for checksum resumed file
|
||||
*sizeCopied += copySize;
|
||||
|
||||
LOG_DETAIL_PID_FMT(
|
||||
processId, "checksum resumed file %s (%s)%s", strZ(fileLog), strZ(logProgress), strZ(logChecksum));
|
||||
}
|
||||
@ -1224,9 +1218,6 @@ backupJobResult(
|
||||
// Else file was copied so update manifest
|
||||
else
|
||||
{
|
||||
// Increment size of files copied
|
||||
*sizeCopied += copySize;
|
||||
|
||||
// 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
|
||||
// ??? The name should be a pg path not manifest name -- can be fixed after the migration
|
||||
@ -1626,7 +1617,7 @@ static ProtocolParallelJob *backupJobCallback(void *data, unsigned int clientIdx
|
||||
FUNCTION_TEST_RETURN(result);
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
static void
|
||||
backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart, const String *cipherPassBackup)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelDebug);
|
||||
@ -1639,7 +1630,6 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
|
||||
ASSERT(manifest != NULL);
|
||||
|
||||
uint64_t sizeTotal = 0;
|
||||
uint64_t sizeCopied = 0;
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
@ -1747,8 +1737,8 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
|
||||
backupStandby && protocolParallelJobProcessId(job) > 1 ? backupData->hostStandby : backupData->hostPrimary,
|
||||
storagePathP(
|
||||
protocolParallelJobProcessId(job) > 1 ? storagePgIdx(pgIdx) : backupData->storagePrimary,
|
||||
manifestPathPg(manifestFileFind(manifest, varStr(protocolParallelJobKey(job)))->name)),
|
||||
fileRemove, job, sizeTotal, &sizeProgress, &sizeCopied);
|
||||
manifestPathPg(manifestFileFind(manifest, varStr(protocolParallelJobKey(job)))->name)), fileRemove, job,
|
||||
sizeTotal, &sizeProgress);
|
||||
}
|
||||
|
||||
// A keep-alive is required here for the remote holding open the backup connection
|
||||
@ -1826,7 +1816,7 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
FUNCTION_LOG_RETURN(UINT64, sizeCopied);
|
||||
FUNCTION_LOG_RETURN_VOID();
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -2107,10 +2097,10 @@ cmdBackup(void)
|
||||
backupManifestSaveCopy(manifest, cipherPassBackup);
|
||||
|
||||
// Process the backup manifest
|
||||
uint64_t backupSizeTotal = backupProcess(backupData, manifest, backupStartResult.lsn, cipherPassBackup);
|
||||
backupProcess(backupData, manifest, backupStartResult.lsn, cipherPassBackup);
|
||||
|
||||
// Stop the backup
|
||||
BackupStopResult backupStopResult = backupStop(backupData, manifest, &backupSizeTotal);
|
||||
BackupStopResult backupStopResult = backupStop(backupData, manifest);
|
||||
|
||||
// Complete manifest
|
||||
manifestBuildComplete(
|
||||
@ -2139,7 +2129,8 @@ cmdBackup(void)
|
||||
// Backup info
|
||||
LOG_INFO_FMT(
|
||||
"%s backup size = %s, file total = %u", strZ(strIdToStr(manifestData(manifest)->backupType)),
|
||||
strZ(strSizeFormat(backupSizeTotal)), manifestFileTotal(manifest));
|
||||
strZ(strSizeFormat(infoBackupDataByLabel(infoBackup, manifestData(manifest)->backupLabel)->backupInfoSizeDelta)),
|
||||
manifestFileTotal(manifest));
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
|
@ -1427,7 +1427,7 @@ testRun(void)
|
||||
ProtocolParallelJob *job = protocolParallelJobNew(VARSTRDEF("key"), protocolCommandNew(strIdFromZ("x")));
|
||||
protocolParallelJobErrorSet(job, errorTypeCode(&AssertError), STRDEF("error message"));
|
||||
|
||||
TEST_ERROR(backupJobResult((Manifest *)1, NULL, STRDEF("log"), strLstNew(), job, 0, NULL, NULL), AssertError, "error message");
|
||||
TEST_ERROR(backupJobResult((Manifest *)1, NULL, STRDEF("log"), strLstNew(), job, 0, NULL), AssertError, "error message");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("report host/100% progress on noop result");
|
||||
@ -1456,10 +1456,9 @@ testRun(void)
|
||||
OBJ_NEW_END();
|
||||
|
||||
uint64_t sizeProgress = 0;
|
||||
uint64_t sizeCopied = 0;
|
||||
|
||||
TEST_RESULT_VOID(
|
||||
backupJobResult(manifest, STRDEF("host"), STRDEF("log-test"), strLstNew(), job, 0, &sizeProgress, &sizeCopied), "log noop result");
|
||||
backupJobResult(manifest, STRDEF("host"), STRDEF("log-test"), strLstNew(), job, 0, &sizeProgress), "log noop result");
|
||||
|
||||
TEST_RESULT_LOG("P00 DETAIL: match file from prior backup host:log-test (0B, 100%)");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user