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

Do not store references for zero-length files when bundling.

This appears to have been an oversight in 34d6495. Storing the reference is not really correct since the file is not stored in a prior backup. It also uses more space.

There is no real harm in storing the reference, since it is always ignored on restore, but the code is simpler if the zero-length files can be dealt with during the manifest and don't need additional handling later on. This is also an important part of some upcoming optimizations.
This commit is contained in:
David Steele 2022-10-04 13:22:31 -10:00 committed by GitHub
parent f0acc195c0
commit f981fb45d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 6 deletions

View File

@ -33,6 +33,19 @@
</release-item>
</release-bug-list>
<release-improvement-list>
<release-item>
<github-pull-request id="1887"/>
<release-item-contributor-list>
<release-item-contributor id="david.steele"/>
<release-item-reviewer id="stefan.fercot"/>
</release-item-contributor-list>
<p>Do not store references for zero-length files when bundling.</p>
</release-item>
</release-improvement-list>
<release-development-list>
<release-item>
<github-pull-request id="1879"/>

View File

@ -1535,10 +1535,6 @@ backupProcessQueue(const BackupData *const backupData, Manifest *const manifest,
const ManifestFilePack *const filePack = manifestFilePackGet(manifest, fileIdx);
const ManifestFile file = manifestFileUnpack(manifest, filePack);
// If the file is a reference it should only be backed up if delta and not zero size
if (file.reference != NULL && (!jobData->delta || file.size == 0))
continue;
// If bundling store zero-length files immediately in the manifest without copying them
if (jobData->bundle && file.size == 0)
{
@ -1550,6 +1546,10 @@ backupProcessQueue(const BackupData *const backupData, Manifest *const manifest,
continue;
}
// If the file is a reference it should only be backed up if delta and not zero size
if (file.reference != NULL && (!jobData->delta || file.size == 0))
continue;
// Is pg_control in the backup?
if (strEq(file.name, STRDEF(MANIFEST_TARGET_PGDATA "/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL)))
pgControlFound = true;

View File

@ -1943,6 +1943,13 @@ sub restoreCompare
foreach my $strName ($oActualManifest->keys(MANIFEST_SECTION_TARGET_FILE))
{
# When bundling zero-length files will not have a reference
if ($oExpectedManifestRef->{&MANIFEST_SECTION_BACKUP}{'backup-bundle'} &&
$oExpectedManifestRef->{&MANIFEST_SECTION_TARGET_FILE}{$strName}{&MANIFEST_SUBKEY_SIZE} == 0)
{
$oActualManifest->remove(MANIFEST_SECTION_TARGET_FILE, $strName, MANIFEST_SUBKEY_REFERENCE);
}
# If synthetic match checksum errors since they can't be verified here
if ($self->synthetic)
{

View File

@ -3357,10 +3357,10 @@ testRun(void)
"P00 INFO: execute non-exclusive pg_start_backup(): backup begins after the next regular checkpoint completes\n"
"P00 INFO: backup start archive = 0000000105DBBF8000000000, lsn = 5dbbf80/0\n"
"P00 INFO: check archive for segment 0000000105DBBF8000000000\n"
"P00 DETAIL: store zero-length file " TEST_PATH "/pg1/zero\n"
"P01 DETAIL: backup file " TEST_PATH "/pg1/global/pg_control (bundle 1/0, 8KB, [PCT]) checksum [SHA1]\n"
"P01 DETAIL: match file from prior backup " TEST_PATH "/pg1/PG_VERSION (2B, [PCT]) checksum [SHA1]\n"
"P00 DETAIL: reference pg_data/PG_VERSION to 20191030-014640F\n"
"P00 DETAIL: reference pg_data/zero to 20191030-014640F\n"
"P00 INFO: execute non-exclusive pg_stop_backup() and wait for all WAL segments to archive\n"
"P00 INFO: backup stop archive = 0000000105DBBF8000000001, lsn = 5dbbf80/300000\n"
"P00 DETAIL: wrote 'backup_label' file returned from pg_stop_backup()\n"
@ -3389,7 +3389,7 @@ testRun(void)
"pg_data/global/pg_control={\"size\":8192,\"timestamp\":1572600000}\n"
"pg_data/tablespace_map={\"checksum\":\"87fe624d7976c2144e10afcb7a9a49b071f35e9c\",\"size\":19"
",\"timestamp\":1572600002}\n"
"pg_data/zero={\"reference\":\"20191030-014640F\",\"size\":0,\"timestamp\":1572600000}\n"
"pg_data/zero={\"size\":0,\"timestamp\":1572600000}\n"
"\n"
"[target:path]\n"
"pg_data={}\n"