You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-06-20 01:17:49 +02:00
Use a storage feature to gate remove errorOnMissing.
The Azure, GCS, and S3 drivers each asserted that errorOnMissing was never set in their remove function, hardcoding in every driver the fact that it cannot detect a missing file on remove. That capability was implied by an assert scattered across the drivers rather than declared anywhere. Add a storageFeatureFileRemoveMissing feature that a driver sets when it can report a file as missing on remove, and enable it for the Posix driver (but not CIFS, which shares the driver). Move the check into storageRemove(), which now asserts errorOnMissing is set only when the storage supports the feature, and drop the redundant per-driver asserts along with the now-unused errorOnMissing log parameter.
This commit is contained in:
@@ -968,12 +968,11 @@ storageAzureRemove(THIS_VOID, const String *const file, const StorageInterfaceRe
|
||||
FUNCTION_LOG_BEGIN(logLevelDebug);
|
||||
FUNCTION_LOG_PARAM(STORAGE_AZURE, this);
|
||||
FUNCTION_LOG_PARAM(STRING, file);
|
||||
FUNCTION_LOG_PARAM(BOOL, param.errorOnMissing);
|
||||
(void)param;
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(this != NULL);
|
||||
ASSERT(file != NULL);
|
||||
ASSERT(!param.errorOnMissing);
|
||||
|
||||
statInc(AZURE_STAT_REMOVE_STR);
|
||||
httpResponseFree(storageAzureRequestP(this, HTTP_VERB_DELETE_STR, file, .allowMissing = true));
|
||||
|
||||
@@ -1154,12 +1154,11 @@ storageGcsRemove(THIS_VOID, const String *const file, const StorageInterfaceRemo
|
||||
FUNCTION_LOG_BEGIN(logLevelDebug);
|
||||
FUNCTION_LOG_PARAM(STORAGE_GCS, this);
|
||||
FUNCTION_LOG_PARAM(STRING, file);
|
||||
FUNCTION_LOG_PARAM(BOOL, param.errorOnMissing);
|
||||
(void)param;
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(this != NULL);
|
||||
ASSERT(file != NULL);
|
||||
ASSERT(!param.errorOnMissing);
|
||||
|
||||
statInc(GCS_STAT_REMOVE_STR);
|
||||
httpResponseFree(storageGcsRequestP(this, HTTP_VERB_DELETE_STR, .object = file, .allowMissing = true));
|
||||
|
||||
@@ -630,7 +630,7 @@ storagePosixNewInternal(
|
||||
{
|
||||
this->interface.feature |=
|
||||
1 << storageFeatureHardLink | (unsigned int)symLink << storageFeatureSymLink | 1 << storageFeaturePathSync |
|
||||
1 << storageFeatureInfoDetail;
|
||||
1 << storageFeatureInfoDetail | 1 << storageFeatureFileRemoveMissing;
|
||||
}
|
||||
}
|
||||
OBJ_NEW_END();
|
||||
|
||||
@@ -1205,12 +1205,11 @@ storageS3Remove(THIS_VOID, const String *const file, const StorageInterfaceRemov
|
||||
FUNCTION_LOG_BEGIN(logLevelDebug);
|
||||
FUNCTION_LOG_PARAM(STORAGE_S3, this);
|
||||
FUNCTION_LOG_PARAM(STRING, file);
|
||||
FUNCTION_LOG_PARAM(BOOL, param.errorOnMissing);
|
||||
(void)param;
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(this != NULL);
|
||||
ASSERT(file != NULL);
|
||||
ASSERT(!param.errorOnMissing);
|
||||
|
||||
httpResponseFree(storageS3RequestP(this, HTTP_VERB_DELETE_STR, file));
|
||||
|
||||
|
||||
@@ -812,6 +812,7 @@ storageRemove(const Storage *const this, const String *const fileExp, const Stor
|
||||
|
||||
ASSERT(this != NULL);
|
||||
ASSERT(this->write);
|
||||
ASSERT(!param.errorOnMissing || storageFeature(this, storageFeatureFileRemoveMissing));
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
|
||||
@@ -63,6 +63,9 @@ typedef enum
|
||||
|
||||
// Can reads be retried?
|
||||
storageFeatureReadRetry,
|
||||
|
||||
// Can files be detected as missing on remove?
|
||||
storageFeatureFileRemoveMissing,
|
||||
} StorageFeature;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
||||
@@ -651,7 +651,8 @@ hrnStorageTestNew(
|
||||
static const StorageInterface hrnStorageInterfaceTest =
|
||||
{
|
||||
.feature =
|
||||
1 << storageFeaturePath | 1 << storageFeaturePathSync | 1 << storageFeatureInfoDetail | 1 << storageFeatureVersioning,
|
||||
1 << storageFeaturePath | 1 << storageFeaturePathSync | 1 << storageFeatureInfoDetail | 1 << storageFeatureVersioning |
|
||||
1 << storageFeatureFileRemoveMissing,
|
||||
|
||||
.info = hrnStorageTestInfo,
|
||||
.list = hrnStorageTestList,
|
||||
|
||||
@@ -1739,6 +1739,13 @@ testRun(void)
|
||||
|
||||
// Test the path sync function -- pass a bogus path to ensure that this is a noop
|
||||
TEST_RESULT_VOID(storagePathSyncP(storage, STRDEF(BOGUS_STR)), "path sync is a noop");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("remove file with errorOnMissing not supported");
|
||||
|
||||
TEST_ERROR(
|
||||
storageRemoveP(storage, STRDEF(BOGUS_STR), .errorOnMissing = true), AssertError,
|
||||
"assertion '!param.errorOnMissing || storageFeature(this, storageFeatureFileRemoveMissing)' failed");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user