1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-05 15:05:48 +02:00

Do not delete manifests individually during stanza delete.

This appears to have been an attempt to not delete files that we don't recognize, but it only works in narrow cases and could leave the user is a position of not being able to complete the stanza delete without manual intervention. It seems better just to proceed with the delete, especially since the info files have already been removed.

In addition, deleting the manifests individually could be slow on object stores if there were a very large number of backups.
This commit is contained in:
David Steele 2021-11-08 09:39:58 -05:00
parent bb03b3f419
commit d05d6b8714
2 changed files with 1 additions and 77 deletions

View File

@ -17,39 +17,6 @@ Stanza Delete Command
#include "protocol/helper.h"
#include "storage/helper.h"
/***********************************************************************************************************************************
Helper functions to assist with testing
***********************************************************************************************************************************/
static void
manifestDelete(const Storage *storageRepoWriteStanza)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(STORAGE, storageRepoWriteStanza);
FUNCTION_TEST_END();
ASSERT(storageRepoWriteStanza != NULL);
// Get the list of backup directories from newest to oldest since don't want to invalidate a backup before
// invalidating any backups that depend on it.
StringList *backupList = strLstSort(
storageListP(
storageRepo(), STORAGE_REPO_BACKUP_STR,
.expression = backupRegExpP(.full = true, .differential = true, .incremental = true)),
sortOrderDesc);
// Delete all manifest files
for (unsigned int idx = 0; idx < strLstSize(backupList); idx++)
{
storageRemoveP(
storageRepoWriteStanza, strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(strLstGet(backupList, idx))));
storageRemoveP(
storageRepoWriteStanza,
strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE INFO_COPY_EXT, strZ(strLstGet(backupList, idx))));
}
FUNCTION_TEST_RETURN_VOID();
}
static bool
stanzaDelete(const Storage *storageRepoWriteStanza, const StringList *archiveList, const StringList *backupList)
{
@ -106,9 +73,6 @@ stanzaDelete(const Storage *storageRepoWriteStanza, const StringList *archiveLis
storageRemoveP(storageRepoWriteStanza, INFO_BACKUP_PATH_FILE_STR);
storageRemoveP(storageRepoWriteStanza, INFO_BACKUP_PATH_FILE_COPY_STR);
}
// Remove manifest files
manifestDelete(storageRepoWriteStanza);
}
// Recursively remove the entire stanza repo if exists. S3 will attempt to remove even if not.

View File

@ -899,7 +899,7 @@ testRun(void)
}
// *****************************************************************************************************************************
if (testBegin("cmdStanzaDelete(), stanzaDelete(), manifestDelete()"))
if (testBegin("cmdStanzaDelete(), stanzaDelete()"))
{
// Load Parameters
StringList *argListCmd = strLstNew();
@ -977,46 +977,6 @@ testRun(void)
TEST_STORAGE_LIST(
storageTest, "repo/backup", "otherstanza/\n", .noRecurse=true, .comment = "stanza '" TEST_STANZA "' deleted");
//--------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("stanza-delete - error on file that looks like backup directory");
// Create a backup file that matches the regex for a backup directory
HRN_STORAGE_PUT_EMPTY(
storageRepoWrite(), STORAGE_REPO_BACKUP "/20190708-154306F", .comment = "backup file that looks like a directory");
HRN_STORAGE_PUT_EMPTY(storageHrn, strZ(lockStopFileName(cfgOptionStr(cfgOptStanza))), .comment = "create stop file");
TEST_ERROR(
cmdStanzaDelete(), FileRemoveError,
"unable to remove '" TEST_PATH "/repo/backup/db/20190708-154306F/backup.manifest': [20] Not a directory");
HRN_STORAGE_REMOVE(storageTest, "repo/backup/db/20190708-154306F", "cleanup - remove backup file");
//--------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("manifestDelete()");
// Create backup manifests
HRN_STORAGE_PUT_EMPTY(storageRepoWrite(), STORAGE_REPO_BACKUP "/20190708-154306F/" BACKUP_MANIFEST_FILE);
HRN_STORAGE_PUT_EMPTY(
storageRepoWrite(), STORAGE_REPO_BACKUP "/20190708-154306F_20190716-191726I/" BACKUP_MANIFEST_FILE INFO_COPY_EXT);
HRN_STORAGE_PUT_EMPTY(storageRepoWrite(), STORAGE_REPO_BACKUP "/20190708-154306F_20190716-191800D/" BACKUP_MANIFEST_FILE);
HRN_STORAGE_PUT_EMPTY(
storageRepoWrite(), STORAGE_REPO_BACKUP "/20190708-154306F_20190716-191800D/" BACKUP_MANIFEST_FILE INFO_COPY_EXT);
TEST_STORAGE_LIST(
storageRepoWrite(), STORAGE_REPO_BACKUP,
"20190708-154306F/\n"
"20190708-154306F/backup.manifest\n"
"20190708-154306F_20190716-191726I/\n"
"20190708-154306F_20190716-191726I/backup.manifest.copy\n"
"20190708-154306F_20190716-191800D/\n"
"20190708-154306F_20190716-191800D/backup.manifest\n"
"20190708-154306F_20190716-191800D/backup.manifest.copy\n");
TEST_RESULT_VOID(manifestDelete(storageRepoWrite()), "delete manifests");
TEST_STORAGE_LIST(
storageRepoWrite(), STORAGE_REPO_BACKUP,
"20190708-154306F/\n"
"20190708-154306F_20190716-191726I/\n"
"20190708-154306F_20190716-191800D/\n", .comment = "all manifest files deleted");
//--------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("stanza-delete - empty directories");