You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-13 01:00:23 +02:00
Improve archive-push command fault tolerance.
3b8f0ef
missed some cases that could cause archive-push to fail:
* Checking archive info.
* Checking to see if a WAL segment already exists.
These cases are now handled so archive-push can succeed on any valid repos.
This commit is contained in:
@ -133,9 +133,10 @@ testRun(void)
|
||||
"1={\"db-id\":5555555555555555555,\"db-version\":\"9.4\"}\n"));
|
||||
|
||||
TEST_ERROR(
|
||||
archivePushCheck(true), ArchiveMismatchError,
|
||||
"PostgreSQL version 9.6, system-id 18072658121562454734 do not match repo1 stanza version 9.4, system-id"
|
||||
" 5555555555555555555"
|
||||
archivePushCheck(true), RepoInvalidError,
|
||||
"unable to find a valid repository:\n"
|
||||
"repo1: [ArchiveMismatchError] PostgreSQL version 9.6, system-id 18072658121562454734 do not match repo1 stanza version"
|
||||
" 9.4, system-id 5555555555555555555"
|
||||
"\nHINT: are you archiving to the correct stanza?");
|
||||
|
||||
// Fix the version
|
||||
@ -149,9 +150,10 @@ testRun(void)
|
||||
"1={\"db-id\":5555555555555555555,\"db-version\":\"9.6\"}\n"));
|
||||
|
||||
TEST_ERROR(
|
||||
archivePushCheck(true), ArchiveMismatchError,
|
||||
"PostgreSQL version 9.6, system-id 18072658121562454734 do not match repo1 stanza version 9.6, system-id"
|
||||
" 5555555555555555555"
|
||||
archivePushCheck(true), RepoInvalidError,
|
||||
"unable to find a valid repository:\n"
|
||||
"repo1: [ArchiveMismatchError] PostgreSQL version 9.6, system-id 18072658121562454734 do not match repo1 stanza version"
|
||||
" 9.6, system-id 5555555555555555555"
|
||||
"\nHINT: are you archiving to the correct stanza?");
|
||||
|
||||
// Fix archive info
|
||||
@ -169,9 +171,12 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_UINT(result.pgVersion, PG_VERSION_96, "check pg version");
|
||||
TEST_RESULT_UINT(result.pgSystemId, 0xFACEFACEFACEFACE, "check pg system id");
|
||||
TEST_RESULT_STR_Z(result.repoData[0].archiveId, "9.6-1", "check archive id");
|
||||
TEST_RESULT_UINT(result.repoData[0].cipherType, cipherTypeNone, "check cipher type");
|
||||
TEST_RESULT_STR_Z(result.repoData[0].cipherPass, NULL, "check cipher pass (not set in this test)");
|
||||
|
||||
ArchivePushFileRepoData *repoData = lstGet(result.repoList, 0);
|
||||
TEST_RESULT_UINT(repoData->repoIdx, 0, "check repo idx");
|
||||
TEST_RESULT_STR_Z(repoData->archiveId, "9.6-1", "check archive id");
|
||||
TEST_RESULT_UINT(repoData->cipherType, cipherTypeNone, "check cipher type");
|
||||
TEST_RESULT_STR_Z(repoData->cipherPass, NULL, "check cipher pass (not set in this test)");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("mismatched repos when pg-path not present");
|
||||
@ -202,11 +207,22 @@ testRun(void)
|
||||
"[db:history]\n"
|
||||
"1={\"db-id\":5555555555555555555,\"db-version\":\"9.4\"}\n"));
|
||||
|
||||
TEST_ERROR(
|
||||
archivePushCheck(false), ArchiveMismatchError,
|
||||
"repo2 stanza version 9.6, system-id 18072658121562454734 do not match repo4 stanza version 9.4, system-id"
|
||||
" 5555555555555555555"
|
||||
"\nHINT: are you archiving to the correct stanza?");
|
||||
TEST_ASSIGN(result, archivePushCheck(false), "get archive check result");
|
||||
|
||||
TEST_RESULT_UINT(result.pgVersion, PG_VERSION_96, "check pg version");
|
||||
TEST_RESULT_UINT(result.pgSystemId, 0xFACEFACEFACEFACE, "check pg system id");
|
||||
TEST_RESULT_STRLST_Z(
|
||||
result.errorList,
|
||||
"repo4: [ArchiveMismatchError] repo2 stanza version 9.6, system-id 18072658121562454734 do not match repo4 stanza"
|
||||
" version 9.4, system-id 5555555555555555555\n"
|
||||
"HINT: are you archiving to the correct stanza?\n",
|
||||
"check error list");
|
||||
|
||||
repoData = lstGet(result.repoList, 0);
|
||||
TEST_RESULT_UINT(repoData->repoIdx, 0, "check repo idx");
|
||||
TEST_RESULT_STR_Z(repoData->archiveId, "9.6-1", "check archive id");
|
||||
TEST_RESULT_UINT(repoData->cipherType, cipherTypeNone, "check cipher type");
|
||||
TEST_RESULT_STR_Z(repoData->cipherPass, NULL, "check cipher pass (not set in this test)");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("matched repos when pg-path not present");
|
||||
@ -226,12 +242,18 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_UINT(result.pgVersion, PG_VERSION_96, "check pg version");
|
||||
TEST_RESULT_UINT(result.pgSystemId, 0xFACEFACEFACEFACE, "check pg system id");
|
||||
TEST_RESULT_STR_Z(result.repoData[0].archiveId, "9.6-1", "check repo2 archive id");
|
||||
TEST_RESULT_UINT(result.repoData[0].cipherType, cipherTypeNone, "check repo2 cipher pass");
|
||||
TEST_RESULT_STR_Z(result.repoData[0].cipherPass, NULL, "check repo2 cipher pass (not set in this test)");
|
||||
TEST_RESULT_STR_Z(result.repoData[1].archiveId, "9.6-2", "check repo4 archive id");
|
||||
TEST_RESULT_UINT(result.repoData[1].cipherType, cipherTypeNone, "check repo4 cipher type");
|
||||
TEST_RESULT_STR_Z(result.repoData[1].cipherPass, NULL, "check repo4 cipher pass (not set in this test)");
|
||||
|
||||
repoData = lstGet(result.repoList, 0);
|
||||
TEST_RESULT_UINT(repoData->repoIdx, 0, "check repo idx");
|
||||
TEST_RESULT_STR_Z(repoData->archiveId, "9.6-1", "check repo2 archive id");
|
||||
TEST_RESULT_UINT(repoData->cipherType, cipherTypeNone, "check repo2 cipher pass");
|
||||
TEST_RESULT_STR_Z(repoData->cipherPass, NULL, "check repo2 cipher pass (not set in this test)");
|
||||
|
||||
repoData = lstGet(result.repoList, 1);
|
||||
TEST_RESULT_UINT(repoData->repoIdx, 1, "check repo idx");
|
||||
TEST_RESULT_STR_Z(repoData->archiveId, "9.6-2", "check repo4 archive id");
|
||||
TEST_RESULT_UINT(repoData->cipherType, cipherTypeNone, "check repo4 cipher type");
|
||||
TEST_RESULT_STR_Z(repoData->cipherPass, NULL, "check repo4 cipher pass (not set in this test)");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
@ -435,6 +457,9 @@ testRun(void)
|
||||
varLstAdd(paramList, varNewStrZ("000000010000000100000002"));
|
||||
varLstAdd(paramList, varNewBool(false));
|
||||
varLstAdd(paramList, varNewInt(6));
|
||||
varLstAdd(paramList, varNewVarLst(varLstNewStrLst(strLstNew())));
|
||||
varLstAdd(paramList, varNewUInt(1));
|
||||
varLstAdd(paramList, varNewUInt(0));
|
||||
varLstAdd(paramList, varNewStrZ("11-1"));
|
||||
varLstAdd(paramList, varNewUInt64(cipherTypeNone));
|
||||
varLstAdd(paramList, NULL);
|
||||
@ -564,6 +589,50 @@ testRun(void)
|
||||
"P00 WARN: WAL file '000000010000000100000002' already exists in the repo3 archive with the same checksum\n"
|
||||
" HINT: this is valid in some recovery scenarios but may also indicate a problem.\n"
|
||||
"P00 INFO: pushed WAL file '000000010000000100000002' to the archive");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("push succeeds on one repo when other repo fails to load archive.info");
|
||||
|
||||
TEST_STORAGE_REMOVE(
|
||||
storageTest, strZ(strNewFmt("repo2/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)));
|
||||
TEST_STORAGE_REMOVE(
|
||||
storageTest, strZ(strNewFmt("repo3/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)));
|
||||
HRN_STORAGE_MODE(storageTest, "repo2", .mode = 0200);
|
||||
|
||||
TEST_ERROR(
|
||||
cmdArchivePush(), CommandError,
|
||||
"archive-push command encountered error(s):\n"
|
||||
"repo2: [FileOpenError] unable to load info file '{[path]}/repo2/archive/test/archive.info' or"
|
||||
" '{[path]}/repo2/archive/test/archive.info.copy':\n"
|
||||
"FileOpenError: unable to open file '{[path]}/repo2/archive/test/archive.info' for read: [13] Permission denied\n"
|
||||
"FileOpenError: unable to open file '{[path]}/repo2/archive/test/archive.info.copy' for read: [13] Permission denied\n"
|
||||
"HINT: archive.info cannot be opened but is required to push/get WAL segments.\n"
|
||||
"HINT: is archive_command configured correctly in postgresql.conf?\n"
|
||||
"HINT: has a stanza-create been performed?\n"
|
||||
"HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving scheme.");
|
||||
|
||||
// Make sure WAL got pushed to repo3
|
||||
TEST_STORAGE_REMOVE(
|
||||
storageTest, strZ(strNewFmt("repo3/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)));
|
||||
|
||||
HRN_STORAGE_MODE(storageTest, "repo2");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("push succeeds on one repo when other repo fails to read path");
|
||||
|
||||
HRN_STORAGE_MODE(storageTest, "repo2/archive/test/11-1", .mode = 0200);
|
||||
|
||||
TEST_ERROR(
|
||||
cmdArchivePush(), CommandError,
|
||||
"archive-push command encountered error(s):\n"
|
||||
"repo2: [PathOpenError] unable to list file info for path '{[path]}/repo2/archive/test/11-1/0000000100000001': [13]"
|
||||
" Permission denied");
|
||||
|
||||
// Make sure WAL got pushed to repo3
|
||||
TEST_STORAGE_REMOVE(
|
||||
storageTest, strZ(strNewFmt("repo3/archive/test/11-1/0000000100000001/000000010000000100000002-%s", walBuffer2Sha1)));
|
||||
|
||||
HRN_STORAGE_MODE(storageTest, "repo2/archive/test/11-1");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
|
Reference in New Issue
Block a user