1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Do not write files atomically or sync paths during backup copy.

There is no need to write the file atomically (e.g. via a temp file on Posix) because checksums are tested on resume after a failed backup. The path does not need be synced for each file because all paths are synced at the end of the backup.

This functionality was not lost during the migration -- it never existed in the Perl code, though these settings are used in restore. See 59f1353 where backupFile() was migrated to C.
This commit is contained in:
David Steele
2021-04-23 12:33:25 -04:00
committed by GitHub
parent aaa15b9709
commit aa72c19a83
3 changed files with 21 additions and 11 deletions

View File

@ -40,7 +40,7 @@
</release-item>
</release-bug-list>
<release-improvement-list>
<release-feature-list>
<release-item>
<github-issue id="986"/>
<github-pull-request id="1337"/>
@ -52,6 +52,21 @@
<p>Add <br-option>db-exclude</br-option> option.</p>
</release-item>
</release-feature-list>
<release-improvement-list>
<release-item>
<github-issue id="1373"/>
<release-item-contributor-list>
<release-item-contributor id="david.steele"/>
<release-item-reviewer id="stephen.frost"/>
<release-item-reviewer id="stefan.fercot"/>
<release-item-reviewer id="cynthia.shang"/>
</release-item-contributor-list>
<p>Do not write files atomically or sync paths during <cmd>backup</cmd> copy.</p>
</release-item>
</release-improvement-list>
<release-development-list>

View File

@ -227,8 +227,11 @@ backupFile(
storageReadIo(read)), cipherBlockNew(cipherModeEncrypt, cipherType, BUFSTR(cipherPass), NULL));
}
// Setup the repo file for write
StorageWrite *write = storageNewWriteP(storageRepoWrite(), repoPathFile, .compressible = compressible);
// Setup the repo file for write. There is no need to write the file atomically (e.g. via a temp file on Posix) because
// checksums are tested on resume after a failed backup. The path does not need to be synced for each file because all
// paths are synced at the end of the backup.
StorageWrite *write = storageNewWriteP(
storageRepoWrite(), repoPathFile, .compressible = compressible, .noAtomic = true, .noSyncPath = true);
ioFilterGroupAdd(ioWriteFilterGroup(storageWriteIo(write)), ioSizeNew());
// Open the source and destination and copy the file

View File

@ -535,11 +535,6 @@ testRun(void)
uint64_t feature = storageRepo()->pub.interface.feature;
((Storage *)storageRepo())->pub.interface.feature = feature & ((1 << storageFeatureCompress) ^ 0xFFFFFFFFFFFFFFFF);
// Create tmp file to make it look like a prior backup file failed partway through to ensure that retries work
TEST_RESULT_VOID(
storagePutP(storageNewWriteP(storageRepoWrite(), strNewFmt("%s.pgbackrest.tmp", strZ(backupPathFile))), NULL),
" create tmp file");
TEST_ASSIGN(
result,
backupFile(
@ -556,9 +551,6 @@ testRun(void)
storageExistsP(storageRepo(), backupPathFile) && result.pageChecksumResult == NULL),
true, " copy file to repo success");
TEST_RESULT_BOOL(
storageExistsP(storageRepoWrite(), strNewFmt("%s.pgbackrest.tmp", strZ(backupPathFile))), false,
" check temp file removed");
TEST_RESULT_VOID(storageRemoveP(storageRepoWrite(), backupPathFile), " remove repo file");
// -------------------------------------------------------------------------------------------------------------------------