From 7627f831cd229095f0937c6db9ce06e0061a0d50 Mon Sep 17 00:00:00 2001 From: Anton Ivashkin Date: Thu, 18 Aug 2022 11:43:50 +0300 Subject: [PATCH] Fix tests --- src/Storages/Freeze.cpp | 17 ++++++++++++----- src/Storages/Freeze.h | 11 ++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Storages/Freeze.cpp b/src/Storages/Freeze.cpp index 52eeb9bdf3c..52261cf7705 100644 --- a/src/Storages/Freeze.cpp +++ b/src/Storages/Freeze.cpp @@ -6,7 +6,7 @@ #include /** - * When ClickHouse has frozen data on remote storage it requred 'smart' data removing during UNFREEZE. + * When ClickHouse has frozen data on remote storage it required 'smart' data removing during UNFREEZE. * For remote storage actually frozen not remote data but local metadata with referrers on remote data. * So remote data can be referred from working and frozen data sets (or two frozen) at same time. * In this case during UNFREEZE ClickHouse should remove only local metadata and keep remote data. @@ -20,10 +20,6 @@ namespace DB { -namespace ErrorCodes -{ - extern const int INVALID_PARTITION_VALUE; -} void FreezeMetaData::fill(const StorageReplicatedMergeTree & storage) { @@ -114,6 +110,17 @@ String FreezeMetaData::getFileName(const String & path) return fs::path(path) / "frozen_metadata.txt"; } +Unfreezer::Unfreezer(ContextPtr context) : local_context(context), zookeeper() +{ + const auto & config = local_context->getConfigRef(); + static constexpr auto config_key = "enable_system_unfreeze"; + if (!config.getBool(config_key, false)) { + throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, "Support for SYSTEM UNFREEZE query is disabled. You can enable it via '{}' server setting", config_key); + } + if (local_context->hasZooKeeper()) + zookeeper = local_context->getZooKeeper(); +} + BlockIO Unfreezer::unfreeze(const String & backup_name) { LOG_DEBUG(log, "Unfreezing backup {}", escapeForFileName(backup_name)); diff --git a/src/Storages/Freeze.h b/src/Storages/Freeze.h index eed1900fbd7..31cda41af9d 100644 --- a/src/Storages/Freeze.h +++ b/src/Storages/Freeze.h @@ -36,14 +36,7 @@ public: class Unfreezer { public: - Unfreezer(ContextPtr context) : local_context(context), zookeeper() { - const auto & config = local_context->getConfigRef(); - static constexpr auto config_key = "enable_system_unfreeze"; - if (!config.getBool(config_key, false)) { - throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, "Support for SYSTEM UNFREEZE query is disabled. You can enable it via '{}' server setting", config_key); - } - zookeeper = this->local_context->getZooKeeper(); - } + Unfreezer(ContextPtr context); PartitionCommandsResultInfo unfreezePartitionsFromTableDirectory(MergeTreeData::MatcherFn matcher, const String & backup_name, const Disks & disks, const fs::path & table_directory); BlockIO unfreeze(const String & backup_name); private: @@ -51,7 +44,7 @@ private: zkutil::ZooKeeperPtr zookeeper; Poco::Logger * log = &Poco::Logger::get("Unfreezer"); static constexpr std::string_view backup_directory_prefix = "shadow"; - static bool removeFreezedPart(DiskPtr disk, const String & path, const String & part_name, ContextPtr local_context, zkutil::ZooKeeperPtr zookeeper); + static bool removeFreezedPart(DiskPtr disk, const String & path, const String & part_name, ContextPtr local_context, zkutil::ZooKeeperPtr zookeeper); }; }