1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-10-30 23:37:45 +02:00

Fix block incremental restore issue on non-default repository.

If the selected backup to restore was not in the default (lowest number) repository and block incremental was used, then restore would erroneously try to load the file super block list from the default repository. Specifying --repo would fix this since it changed the default repository.

Fix by updating the super block read to the specified repository.
This commit is contained in:
David Steele
2025-03-21 10:37:20 -06:00
committed by GitHub
parent 723f900eaa
commit 5d2c67c3c6
4 changed files with 38 additions and 14 deletions

View File

@@ -1,6 +1,21 @@
<release date="XXXX-XX-XX" version="2.55.0dev" title="UNDER DEVELOPMENT">
<release-core-list>
<release-bug-list>
<release-item>
<github-issue id="2577"/>
<github-pull-request id="2579"/>
<release-item-contributor-list>
<release-item-ideator id="aleksander.lukasz"/>
<release-item-contributor id="david.steele"/>
<release-item-reviewer id="david.christensen"/>
<!-- Actually tester, but we don't have a tag for that yet -->
<release-item-reviewer id="aleksander.lukasz"/>
</release-item-contributor-list>
<p>Fix block incremental restore issue on non-default repository.</p>
</release-item>
<release-item>
<github-pull-request id="2533"/>

View File

@@ -40,6 +40,11 @@
<contributor-id type="github">ahmed112212</contributor-id>
</contributor>
<contributor id="aleksander.lukasz">
<contributor-name-display>Aleksander &amp;Lstrok;ukasz</contributor-name-display>
<contributor-id type="github">aflukasz</contributor-id>
</contributor>
<contributor id="aleksandr.rogozin">
<contributor-name-display>Aleksandr Rogozin</contributor-name-display>
<contributor-id type="github">arogozin</contributor-id>

View File

@@ -320,7 +320,7 @@ restoreFile(
// Open the super block list for read. Using one read for all super blocks is cheaper than reading from
// the file multiple times, which is especially noticeable on object stores.
StorageRead *const superBlockRead = storageNewReadP(
storageRepo(),
storageRepoIdx(repoIdx),
backupFileRepoPathP(
strLstGet(referenceList, read->reference), .manifestName = file->manifestFile,
.bundleId = read->bundleId, .blockIncr = true),

View File

@@ -3304,11 +3304,14 @@ testRun(void)
argList = strLstNew();
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
hrnCfgArgRaw(argList, cfgOptRepoPath, repoPath);
hrnCfgArgRaw(argList, cfgOptPgPath, pgPath);
hrnCfgArgRawZ(argList, cfgOptSpoolPath, TEST_PATH "/spool");
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, "aes-256-cbc");
hrnCfgEnvRawZ(cfgOptRepoCipherPass, TEST_CIPHER_PASS);
// Configure a bogus repo1 and restore from repo2 to ensure that restore correctly uses the selected repo
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 1, "/bogus");
hrnCfgArgKeyRaw(argList, cfgOptRepoPath, 2, repoPath);
hrnCfgArgKeyRawZ(argList, cfgOptRepoCipherType, 2, "aes-256-cbc");
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS);
HRN_CFG_LOAD(cfgCmdRestore, argList);
TEST_RESULT_VOID(cmdRestore(), "restore");
@@ -3329,6 +3332,17 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("delta restore with block incr");
// Restore configuration to repo1
argList = strLstNew();
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
hrnCfgArgRaw(argList, cfgOptRepoPath, repoPath);
hrnCfgArgRaw(argList, cfgOptPgPath, pgPath);
hrnCfgArgRawZ(argList, cfgOptSpoolPath, TEST_PATH "/spool");
hrnCfgArgRawBool(argList, cfgOptDelta, true);
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, "aes-256-cbc");
hrnCfgEnvRawZ(cfgOptRepoCipherPass, TEST_CIPHER_PASS);
HRN_CFG_LOAD(cfgCmdRestore, argList);
// Get last diff backup label and truncate bundle/1
hrnSleepRemainder();
@@ -3340,16 +3354,6 @@ testRun(void)
HRN_STORAGE_PUT(storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/bundle/1", strZ(backupFull))), NULL);
// Make sure restore fails with the invalid file
argList = strLstNew();
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
hrnCfgArgRaw(argList, cfgOptRepoPath, repoPath);
hrnCfgArgRaw(argList, cfgOptPgPath, pgPath);
hrnCfgArgRawZ(argList, cfgOptSpoolPath, TEST_PATH "/spool");
hrnCfgArgRawBool(argList, cfgOptDelta, true);
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, "aes-256-cbc");
hrnCfgEnvRawZ(cfgOptRepoCipherPass, TEST_CIPHER_PASS);
HRN_CFG_LOAD(cfgCmdRestore, argList);
TEST_ERROR(cmdRestore(), CryptoError, "raised from local-1 shim protocol: cipher header missing");
// Use detail log level to catch block incremental restore message