You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-11-06 08:49:29 +02:00
Fix overflow suppressing backup status in info output.
Writing the sz and szCplt parameters in the lock file used jsonWriteUInt64() but reading these parameters used jsonReadUInt(). This caused a silent exception for any backups larger than MAX_UINT and prevented the info command from reporting progress. Correct this so the reads are symmetric and verified before/after with a test.
This commit is contained in:
@@ -1,5 +1,19 @@
|
||||
<release date="XXXX-XX-XX" version="2.50dev" title="Under Development">
|
||||
<release-core-list>
|
||||
<release-bug-list>
|
||||
<release-item>
|
||||
<github-issue id="2251"/>
|
||||
<github-pull-request id="2252"/>
|
||||
|
||||
<release-item-contributor-list>
|
||||
<release-item-contributor id="robert.donovan"/>
|
||||
<release-item-reviewer id="joe.wildish"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Fix overflow suppressing backup progress in <cmd>info</cmd> output.</p>
|
||||
</release-item>
|
||||
</release-bug-list>
|
||||
|
||||
<release-improvement-list>
|
||||
<release-item>
|
||||
<github-pull-request id="2197"/>
|
||||
|
||||
@@ -565,6 +565,11 @@
|
||||
<contributor-id type="github">JBromage</contributor-id>
|
||||
</contributor>
|
||||
|
||||
<contributor id="joe.wildish">
|
||||
<contributor-name-display>Joe Wildish</contributor-name-display>
|
||||
<contributor-id type="github">joewildish</contributor-id>
|
||||
</contributor>
|
||||
|
||||
<contributor id="keith.fiske">
|
||||
<contributor-name-display>Keith Fiske</contributor-name-display>
|
||||
<contributor-id type="github">keithf4</contributor-id>
|
||||
@@ -840,6 +845,11 @@
|
||||
<contributor-id type="github">vidierr</contributor-id>
|
||||
</contributor>
|
||||
|
||||
<contributor id="robert.donovan">
|
||||
<contributor-name-display>Robert Donovan</contributor-name-display>
|
||||
<contributor-id type="github">rob-donovan</contributor-id>
|
||||
</contributor>
|
||||
|
||||
<contributor id="rohit.raveendran">
|
||||
<contributor-name-display>Rohit Raveendran</contributor-name-display>
|
||||
<contributor-id type="github">rohitrav33ndran</contributor-id>
|
||||
|
||||
@@ -156,10 +156,10 @@ lockReadFileData(const String *const lockFile, const int fd)
|
||||
result.processId = jsonReadInt(jsonReadKeyRequireStrId(json, LOCK_KEY_PROCESS_ID));
|
||||
|
||||
if (jsonReadKeyExpectStrId(json, LOCK_KEY_SIZE))
|
||||
result.size = varNewUInt64(jsonReadUInt(json));
|
||||
result.size = varNewUInt64(jsonReadUInt64(json));
|
||||
|
||||
if (jsonReadKeyExpectStrId(json, LOCK_KEY_SIZE_COMPLETE))
|
||||
result.sizeComplete = varNewUInt64(jsonReadUInt(json));
|
||||
result.sizeComplete = varNewUInt64(jsonReadUInt64(json));
|
||||
}
|
||||
MEM_CONTEXT_PRIOR_END();
|
||||
}
|
||||
|
||||
@@ -237,17 +237,19 @@ testRun(void)
|
||||
TEST_RESULT_UINT(varUInt64(lockDataResult.sizeComplete), 1754824, "verify sizeProgress");
|
||||
TEST_RESULT_UINT(varUInt64(lockDataResult.size), 3159000, "verify sizeTotal");
|
||||
|
||||
// The size/sizeComplete values should be large enough to overflow a uint32 to ensure uint64 is used for read/write
|
||||
TEST_RESULT_VOID(
|
||||
lockWriteDataP(
|
||||
lockTypeBackup, .percentComplete = VARUINT(8888), .sizeComplete = VARUINT64(2807719), .size = VARUINT64(3159000)),
|
||||
lockTypeBackup, .percentComplete = VARUINT(8888), .sizeComplete = VARUINT64(3223802441008),
|
||||
.size = VARUINT64(6126216975438)),
|
||||
"write lock data");
|
||||
THROW_ON_SYS_ERROR_FMT(
|
||||
lseek(lockLocal.file[lockTypeBackup].fd, 0, SEEK_SET) == -1, FileOpenError, STORAGE_ERROR_READ_SEEK, (uint64_t)0,
|
||||
strZ(lockLocal.file[lockTypeBackup].name));
|
||||
lockDataResult = lockReadFileData(backupLockFile, lockLocal.file[lockTypeBackup].fd);
|
||||
TEST_RESULT_UINT(varUInt(lockDataResult.percentComplete), 8888, "verify percentComplete");
|
||||
TEST_RESULT_UINT(varUInt64(lockDataResult.sizeComplete), 2807719, "verify sizeProgress");
|
||||
TEST_RESULT_UINT(varUInt64(lockDataResult.size), 3159000, "verify sizeTotal");
|
||||
TEST_RESULT_UINT(varUInt64(lockDataResult.sizeComplete), 3223802441008, "verify sizeProgress");
|
||||
TEST_RESULT_UINT(varUInt64(lockDataResult.size), 6126216975438, "verify sizeTotal");
|
||||
|
||||
TEST_ERROR(
|
||||
lockAcquireP(.returnOnNoLock = true), AssertError,
|
||||
|
||||
Reference in New Issue
Block a user