1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-05-22 10:15:16 +02:00

Skip zero-length files for block incremental delta restore.

a42614e introduced the capability to preserve smaller than expected files for block incremental restore delta, but failed to take into account that zero-length files are both useless and cause the block checksum filter to error.

Fix this by skipping zero-length files during block incremental restore delta.
This commit is contained in:
David Steele
2024-03-02 12:29:10 +13:00
committed by GitHub
parent 6c45b57fa8
commit f7a7ab16c9
4 changed files with 42 additions and 2 deletions
+16
View File
@@ -1,5 +1,21 @@
<release date="XXXX-XX-XX" version="2.51dev" title="UNDER DEVELOPMENT"> <release date="XXXX-XX-XX" version="2.51dev" title="UNDER DEVELOPMENT">
<release-core-list> <release-core-list>
<release-bug-list>
<release-item>
<github-issue id="2271"/>
<github-pull-request id="2272"/>
<release-item-contributor-list>
<release-item-ideator id="sebastian.krause"/>
<release-item-contributor id="david.steele"/>
<release-item-reviewer id="sebastian.krause"/>
<release-item-reviewer id="rene.hojbjerg.larsen"/>
</release-item-contributor-list>
<p>Skip zero-length files for block incremental delta restore.</p>
</release-item>
</release-bug-list>
<release-improvement-list> <release-improvement-list>
<release-item> <release-item>
<github-pull-request id="2263"/> <github-pull-request id="2263"/>
+10
View File
@@ -855,6 +855,11 @@
<contributor-id type="github">vidierr</contributor-id> <contributor-id type="github">vidierr</contributor-id>
</contributor> </contributor>
<contributor id="rene.hojbjerg.larsen">
<contributor-name-display>Ren&amp;eacute; H&amp;oslash;jbjerg Larsen</contributor-name-display>
<contributor-id type="github">rhl-jfm</contributor-id>
</contributor>
<contributor id="robert.donovan"> <contributor id="robert.donovan">
<contributor-name-display>Robert Donovan</contributor-name-display> <contributor-name-display>Robert Donovan</contributor-name-display>
<contributor-id type="github">rob-donovan</contributor-id> <contributor-id type="github">rob-donovan</contributor-id>
@@ -910,6 +915,11 @@
<contributor-id type="github">slardiere</contributor-id> <contributor-id type="github">slardiere</contributor-id>
</contributor> </contributor>
<contributor id="sebastian.krause">
<contributor-name-display>Sebastian Krause</contributor-name-display>
<contributor-id type="github">sekrause</contributor-id>
</contributor>
<contributor id="seth.daniel"> <contributor id="seth.daniel">
<contributor-name-display>Seth Daniel</contributor-name-display> <contributor-name-display>Seth Daniel</contributor-name-display>
<contributor-id type="github">sethdaniel</contributor-id> <contributor-id type="github">sethdaniel</contributor-id>
+4 -2
View File
@@ -88,8 +88,10 @@ restoreFile(
// Else use size and checksum // Else use size and checksum
else else
{ {
// Only continue delta if the file size is as expected or larger // Only continue delta if the file size is as expected or larger (for normal files) or if block
if (info.size >= file->size || file->blockIncrMapSize != 0) // incremental and the file to delta is not zero-length. Block incremental can potentially use almost
// any portion of an existing file, but of course zero-length files do not have anything to reuse.
if (info.size >= file->size || (file->blockIncrMapSize != 0 && info.size != 0))
{ {
const char *const fileName = strZ(storagePathP(storagePg(), file->name)); const char *const fileName = strZ(storagePathP(storagePg(), file->name));
+12
View File
@@ -3165,6 +3165,13 @@ testRun(void)
HRN_STORAGE_PUT(storagePgWrite(), PG_PATH_BASE "/1/2", relation, .timeModified = timeBase - 2); HRN_STORAGE_PUT(storagePgWrite(), PG_PATH_BASE "/1/2", relation, .timeModified = timeBase - 2);
// Zeroed file large enough to use block incr (that will be truncated to zero before restore)
relation = bufNew(16 * 1024);
memset(bufPtr(relation), 0, bufSize(relation));
bufUsedSet(relation, bufSize(relation));
HRN_STORAGE_PUT(storagePgWrite(), PG_PATH_BASE "/1/44", relation, .timeModified = timeBase - 2);
// Add postgresql.auto.conf to contain recovery settings // Add postgresql.auto.conf to contain recovery settings
HRN_STORAGE_PUT_EMPTY(storagePgWrite(), PG_FILE_POSTGRESQLAUTOCONF, .timeModified = timeBase - 1); HRN_STORAGE_PUT_EMPTY(storagePgWrite(), PG_FILE_POSTGRESQLAUTOCONF, .timeModified = timeBase - 1);
@@ -3234,6 +3241,7 @@ testRun(void)
"base/1/\n" "base/1/\n"
"base/1/2\n" "base/1/2\n"
"base/1/3\n" "base/1/3\n"
"base/1/44\n"
"global/\n" "global/\n"
"global/pg_control\n" "global/pg_control\n"
"postgresql.auto.conf\n", "postgresql.auto.conf\n",
@@ -3245,6 +3253,9 @@ testRun(void)
// Use detail log level to catch block incremental restore message // Use detail log level to catch block incremental restore message
harnessLogLevelSet(logLevelDetail); harnessLogLevelSet(logLevelDetail);
// Truncate file to ensure delta is skipped
HRN_STORAGE_PUT_EMPTY(storagePgWrite(), PG_PATH_BASE "/1/44");
// Shrink file to make sure block incremental delta will reuse it // Shrink file to make sure block incremental delta will reuse it
relation = bufNew(128 * 1024); relation = bufNew(128 * 1024);
memset(bufPtr(relation), 0, bufSize(relation)); memset(bufPtr(relation), 0, bufSize(relation));
@@ -3271,6 +3282,7 @@ testRun(void)
"base/1/\n" "base/1/\n"
"base/1/2\n" "base/1/2\n"
"base/1/3\n" "base/1/3\n"
"base/1/44\n"
"global/\n" "global/\n"
"global/pg_control\n" "global/pg_control\n"
"postgresql.auto.conf\n", "postgresql.auto.conf\n",