From 802ee27b1b86b340549b2149c67260bd6c56d32b Mon Sep 17 00:00:00 2001 From: Julia Kartseva Date: Fri, 26 Apr 2024 03:49:07 +0000 Subject: [PATCH] address feedback - pt.3 non-functional changes --- programs/keeper/CMakeLists.txt | 2 +- .../MetadataFromDiskTransactionState.cpp | 23 ------------------- .../MetadataOperationsHolder.cpp | 16 ++++++------- .../ObjectStorages/MetadataOperationsHolder.h | 4 ++-- .../ObjectStorages/MetadataStorageFromDisk.h | 2 +- .../MetadataStorageFromPlainObjectStorage.h | 2 +- .../MetadataStorageTransactionState.cpp | 23 +++++++++++++++++++ ...te.h => MetadataStorageTransactionState.h} | 5 ++-- .../MetadataStorageFromStaticFilesWebServer.h | 6 ++--- 9 files changed, 41 insertions(+), 42 deletions(-) delete mode 100644 src/Disks/ObjectStorages/MetadataFromDiskTransactionState.cpp create mode 100644 src/Disks/ObjectStorages/MetadataStorageTransactionState.cpp rename src/Disks/ObjectStorages/{MetadataFromDiskTransactionState.h => MetadataStorageTransactionState.h} (53%) diff --git a/programs/keeper/CMakeLists.txt b/programs/keeper/CMakeLists.txt index 88964465878..51529036ed5 100644 --- a/programs/keeper/CMakeLists.txt +++ b/programs/keeper/CMakeLists.txt @@ -125,7 +125,7 @@ if (BUILD_STANDALONE_KEEPER) ${CMAKE_CURRENT_SOURCE_DIR}/../../src/Disks/ObjectStorages/MetadataStorageFromPlainObjectStorageOperations.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../../src/Disks/ObjectStorages/MetadataStorageFromPlainObjectStorage.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../../src/Disks/ObjectStorages/MetadataStorageFromDisk.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../src/Disks/ObjectStorages/MetadataFromDiskTransactionState.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../../src/Disks/ObjectStorages/MetadataStorageTransactionState.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../../src/Disks/ObjectStorages/DiskObjectStorageMetadata.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../../src/Disks/ObjectStorages/MetadataStorageFromDiskTransactionOperations.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../../src/Disks/ObjectStorages/DiskObjectStorage.cpp diff --git a/src/Disks/ObjectStorages/MetadataFromDiskTransactionState.cpp b/src/Disks/ObjectStorages/MetadataFromDiskTransactionState.cpp deleted file mode 100644 index f6915370b10..00000000000 --- a/src/Disks/ObjectStorages/MetadataFromDiskTransactionState.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -namespace DB -{ - -std::string toString(MetadataFromDiskTransactionState state) -{ - switch (state) - { - case MetadataFromDiskTransactionState::PREPARING: - return "PREPARING"; - case MetadataFromDiskTransactionState::FAILED: - return "FAILED"; - case MetadataFromDiskTransactionState::COMMITTED: - return "COMMITTED"; - case MetadataFromDiskTransactionState::PARTIALLY_ROLLED_BACK: - return "PARTIALLY_ROLLED_BACK"; - } - UNREACHABLE(); -} - -} diff --git a/src/Disks/ObjectStorages/MetadataOperationsHolder.cpp b/src/Disks/ObjectStorages/MetadataOperationsHolder.cpp index f051f62fa41..3023700631c 100644 --- a/src/Disks/ObjectStorages/MetadataOperationsHolder.cpp +++ b/src/Disks/ObjectStorages/MetadataOperationsHolder.cpp @@ -13,7 +13,7 @@ extern const int FS_METADATA_ERROR; void MetadataOperationsHolder::rollback(size_t until_pos) { /// Otherwise everything is alright - if (state == MetadataFromDiskTransactionState::FAILED) + if (state == MetadataStorageTransactionState::FAILED) { for (int64_t i = until_pos; i >= 0; --i) { @@ -23,7 +23,7 @@ void MetadataOperationsHolder::rollback(size_t until_pos) } catch (Exception & ex) { - state = MetadataFromDiskTransactionState::PARTIALLY_ROLLED_BACK; + state = MetadataStorageTransactionState::PARTIALLY_ROLLED_BACK; ex.addMessage(fmt::format("While rolling back operation #{}", i)); throw; } @@ -37,24 +37,24 @@ void MetadataOperationsHolder::rollback(size_t until_pos) void MetadataOperationsHolder::addOperation(MetadataOperationPtr && operation) { - if (state != MetadataFromDiskTransactionState::PREPARING) + if (state != MetadataStorageTransactionState::PREPARING) throw Exception( ErrorCodes::FS_METADATA_ERROR, "Cannot add operations to transaction in {} state, it should be in {} state", toString(state), - toString(MetadataFromDiskTransactionState::PREPARING)); + toString(MetadataStorageTransactionState::PREPARING)); operations.emplace_back(std::move(operation)); } void MetadataOperationsHolder::commitImpl(SharedMutex & metadata_mutex) { - if (state != MetadataFromDiskTransactionState::PREPARING) + if (state != MetadataStorageTransactionState::PREPARING) throw Exception( ErrorCodes::FS_METADATA_ERROR, "Cannot commit transaction in {} state, it should be in {} state", toString(state), - toString(MetadataFromDiskTransactionState::PREPARING)); + toString(MetadataStorageTransactionState::PREPARING)); { std::unique_lock lock(metadata_mutex); @@ -68,7 +68,7 @@ void MetadataOperationsHolder::commitImpl(SharedMutex & metadata_mutex) { tryLogCurrentException(__PRETTY_FUNCTION__); ex.addMessage(fmt::format("While committing metadata operation #{}", i)); - state = MetadataFromDiskTransactionState::FAILED; + state = MetadataStorageTransactionState::FAILED; rollback(i); throw; } @@ -88,7 +88,7 @@ void MetadataOperationsHolder::commitImpl(SharedMutex & metadata_mutex) } } - state = MetadataFromDiskTransactionState::COMMITTED; + state = MetadataStorageTransactionState::COMMITTED; } } diff --git a/src/Disks/ObjectStorages/MetadataOperationsHolder.h b/src/Disks/ObjectStorages/MetadataOperationsHolder.h index e264df5e094..7c5988a70f8 100644 --- a/src/Disks/ObjectStorages/MetadataOperationsHolder.h +++ b/src/Disks/ObjectStorages/MetadataOperationsHolder.h @@ -3,7 +3,7 @@ #include /// TODO: rename to MetadataStorageTransactionState. -#include +#include /** * Implementations for transactional operations with metadata used by MetadataStorageFromDisk @@ -17,7 +17,7 @@ class MetadataOperationsHolder { private: std::vector operations; - MetadataFromDiskTransactionState state{MetadataFromDiskTransactionState::PREPARING}; + MetadataStorageTransactionState state{MetadataStorageTransactionState::PREPARING}; void rollback(size_t until_pos); diff --git a/src/Disks/ObjectStorages/MetadataStorageFromDisk.h b/src/Disks/ObjectStorages/MetadataStorageFromDisk.h index 5dca40afc59..1346a4dcf93 100644 --- a/src/Disks/ObjectStorages/MetadataStorageFromDisk.h +++ b/src/Disks/ObjectStorages/MetadataStorageFromDisk.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include diff --git a/src/Disks/ObjectStorages/MetadataStorageFromPlainObjectStorage.h b/src/Disks/ObjectStorages/MetadataStorageFromPlainObjectStorage.h index 3820fd893b5..3f5d2f8b260 100644 --- a/src/Disks/ObjectStorages/MetadataStorageFromPlainObjectStorage.h +++ b/src/Disks/ObjectStorages/MetadataStorageFromPlainObjectStorage.h @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include diff --git a/src/Disks/ObjectStorages/MetadataStorageTransactionState.cpp b/src/Disks/ObjectStorages/MetadataStorageTransactionState.cpp new file mode 100644 index 00000000000..245578b5d9e --- /dev/null +++ b/src/Disks/ObjectStorages/MetadataStorageTransactionState.cpp @@ -0,0 +1,23 @@ +#include +#include + +namespace DB +{ + +std::string toString(MetadataStorageTransactionState state) +{ + switch (state) + { + case MetadataStorageTransactionState::PREPARING: + return "PREPARING"; + case MetadataStorageTransactionState::FAILED: + return "FAILED"; + case MetadataStorageTransactionState::COMMITTED: + return "COMMITTED"; + case MetadataStorageTransactionState::PARTIALLY_ROLLED_BACK: + return "PARTIALLY_ROLLED_BACK"; + } + UNREACHABLE(); +} + +} diff --git a/src/Disks/ObjectStorages/MetadataFromDiskTransactionState.h b/src/Disks/ObjectStorages/MetadataStorageTransactionState.h similarity index 53% rename from src/Disks/ObjectStorages/MetadataFromDiskTransactionState.h rename to src/Disks/ObjectStorages/MetadataStorageTransactionState.h index 3dc4c610e3a..fb05d185a37 100644 --- a/src/Disks/ObjectStorages/MetadataFromDiskTransactionState.h +++ b/src/Disks/ObjectStorages/MetadataStorageTransactionState.h @@ -4,7 +4,7 @@ namespace DB { -enum class MetadataFromDiskTransactionState +enum class MetadataStorageTransactionState { PREPARING, FAILED, @@ -12,6 +12,5 @@ enum class MetadataFromDiskTransactionState PARTIALLY_ROLLED_BACK, }; -std::string toString(MetadataFromDiskTransactionState state); - +std::string toString(MetadataStorageTransactionState state); } diff --git a/src/Disks/ObjectStorages/Web/MetadataStorageFromStaticFilesWebServer.h b/src/Disks/ObjectStorages/Web/MetadataStorageFromStaticFilesWebServer.h index b720a9c91f3..35271d7192c 100644 --- a/src/Disks/ObjectStorages/Web/MetadataStorageFromStaticFilesWebServer.h +++ b/src/Disks/ObjectStorages/Web/MetadataStorageFromStaticFilesWebServer.h @@ -1,9 +1,9 @@ #pragma once -#include -#include -#include #include +#include +#include +#include namespace DB