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

Fix info command missing WAL min/max when stanza specified.

This issue was a result of STORAGE_REPO_PATH prepending an extra stanza when the stanza was specified on the command line.

The tests missed this because by some strange coincidence the WAL dirs were empty for each test that specified a stanza.  Add new tests to prevent a regression.

Fixed by Stefan Fercot.
This commit is contained in:
Stefan Fercot
2019-02-21 12:09:12 +02:00
committed by David Steele
parent 1519f5b045
commit 80df1114bd
3 changed files with 39 additions and 5 deletions

View File

@ -22,6 +22,14 @@
<p>Fix possible truncated WAL segments when an error occurs mid-write.</p> <p>Fix possible truncated WAL segments when an error occurs mid-write.</p>
</release-item> </release-item>
<release-item>
<release-item-contributor-list>
<release-item-contributor id="stefan.fercot"/>
</release-item-contributor-list>
<p>Fix info command missing WAL min/max when stanza specified.</p>
</release-item>
</release-bug-list> </release-bug-list>
<release-development-list> <release-development-list>
@ -6528,6 +6536,11 @@
<contributor-id type="github">slardiere</contributor-id> <contributor-id type="github">slardiere</contributor-id>
</contributor> </contributor>
<contributor id="stefan.fercot">
<contributor-name-display>Stefan Fercot</contributor-name-display>
<contributor-id type="github">pgstef</contributor-id>
</contributor>
<contributor id="stephane.schildknecht"> <contributor id="stephane.schildknecht">
<contributor-name-display>St&amp;eacute;phane Schildknecht</contributor-name-display> <contributor-name-display>St&amp;eacute;phane Schildknecht</contributor-name-display>
<contributor-id type="github">saspg</contributor-id> <contributor-id type="github">saspg</contributor-id>

View File

@ -117,7 +117,7 @@ archiveDbList(const String *stanza, const InfoPgData *pgData, VariantList *archi
// If there is no match, an error will be thrown. // If there is no match, an error will be thrown.
const String *archiveId = infoArchiveIdHistoryMatch(info, pgData->id, pgData->version, pgData->systemId); const String *archiveId = infoArchiveIdHistoryMatch(info, pgData->id, pgData->version, pgData->systemId);
String *archivePath = strNewFmt("%s/%s/%s", STORAGE_REPO_ARCHIVE, strPtr(stanza), strPtr(archiveId)); String *archivePath = strNewFmt(STORAGE_PATH_ARCHIVE "/%s/%s", strPtr(stanza), strPtr(archiveId));
String *archiveStart = NULL; String *archiveStart = NULL;
String *archiveStop = NULL; String *archiveStop = NULL;
Variant *archiveInfo = varNewKv(); Variant *archiveInfo = varNewKv();

View File

@ -179,6 +179,30 @@ testRun(void)
" wal archive min/max (9.4-3): none present\n", " wal archive min/max (9.4-3): none present\n",
"text - single stanza, no valid backups"); "text - single stanza, no valid backups");
// Add WAL segments
//--------------------------------------------------------------------------------------------------------------------------
String *archiveDb3 = strNewFmt("%s/9.4-3/0000000100000000", strPtr(archiveStanza1Path));
TEST_RESULT_VOID(storagePathCreateNP(storageLocalWrite(), archiveDb3), "create db3 archive WAL1 directory");
String *archiveDb3Wal = strNewFmt(
"%s/000000010000000000000004-47dff2b7552a9d66e4bae1a762488a6885e7082c.gz", strPtr(archiveDb3));
TEST_RESULT_VOID(storagePutNP(storageNewWriteNP(storageLocalWrite(), archiveDb3Wal), bufNew(0)), "touch WAL3 file");
StringList *argList2 = strLstDup(argListText);
strLstAddZ(argList2, "--stanza=stanza1");
harnessCfgLoad(strLstSize(argList2), strLstPtr(argList2));
TEST_RESULT_STR(strPtr(infoRender()),
"stanza: stanza1\n"
" status: error (no valid backups)\n"
" cipher: aes-256-cbc\n"
"\n"
" db (current)\n"
" wal archive min/max (9.4-3): 000000010000000000000004/000000010000000000000004\n",
"text - single stanza, one wal segment");
TEST_RESULT_VOID(storageRemoveP(storageLocalWrite(), archiveDb3Wal, .errorOnMissing = true), "remove WAL file");
// Coverage for stanzaStatus branches // Coverage for stanzaStatus branches
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
String *archiveDb1_1 = strNewFmt("%s/9.4-1/0000000100000000", strPtr(archiveStanza1Path)); String *archiveDb1_1 = strNewFmt("%s/9.4-1/0000000100000000", strPtr(archiveStanza1Path));
@ -199,9 +223,6 @@ testRun(void)
String *archiveDb1_3 = strNewFmt("%s/9.4-1/0000000300000000", strPtr(archiveStanza1Path)); String *archiveDb1_3 = strNewFmt("%s/9.4-1/0000000300000000", strPtr(archiveStanza1Path));
TEST_RESULT_VOID(storagePathCreateNP(storageLocalWrite(), archiveDb1_3), "create db1 archive WAL3 directory"); TEST_RESULT_VOID(storagePathCreateNP(storageLocalWrite(), archiveDb1_3), "create db1 archive WAL3 directory");
String *archiveDb3 = strNewFmt("%s/9.4-3/0000000100000000", strPtr(archiveStanza1Path));
TEST_RESULT_VOID(storagePathCreateNP(storageLocalWrite(), archiveDb3), "create db3 archive WAL1 directory");
harnessCfgLoad(strLstSize(argList), strLstPtr(argList)); harnessCfgLoad(strLstSize(argList), strLstPtr(argList));
content = strNew content = strNew
( (
@ -664,7 +685,7 @@ testRun(void)
// Stanza not found // Stanza not found
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
StringList *argList2 = strLstDup(argList); argList2 = strLstDup(argList);
strLstAddZ(argList2, "--stanza=silly"); strLstAddZ(argList2, "--stanza=silly");
harnessCfgLoad(strLstSize(argList2), strLstPtr(argList2)); harnessCfgLoad(strLstSize(argList2), strLstPtr(argList2));
TEST_RESULT_STR(strPtr(infoRender()), TEST_RESULT_STR(strPtr(infoRender()),