2022-06-08 12:09:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Storages/StorageReplicatedMergeTree.h>
|
|
|
|
#include <Storages/MergeTree/MergeTreeData.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Special metadata used during freeze table. Required for zero-copy
|
|
|
|
/// replication.
|
|
|
|
struct FreezeMetaData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void fill(const StorageReplicatedMergeTree & storage);
|
|
|
|
|
|
|
|
void save(DiskPtr data_disk, const String & path) const;
|
|
|
|
|
|
|
|
bool load(DiskPtr data_disk, const String & path);
|
|
|
|
|
|
|
|
static void clean(DiskPtr data_disk, const String & path);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static String getFileName(const String & path);
|
|
|
|
|
|
|
|
public:
|
2022-06-21 09:17:52 +00:00
|
|
|
int version = 2;
|
2022-06-08 12:09:59 +00:00
|
|
|
String replica_name;
|
|
|
|
String zookeeper_name;
|
|
|
|
String table_shared_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Unfreezer
|
|
|
|
{
|
|
|
|
public:
|
2022-08-18 08:43:50 +00:00
|
|
|
Unfreezer(ContextPtr context);
|
2022-07-22 10:10:08 +00:00
|
|
|
PartitionCommandsResultInfo unfreezePartitionsFromTableDirectory(MergeTreeData::MatcherFn matcher, const String & backup_name, const Disks & disks, const fs::path & table_directory);
|
2022-08-23 10:59:02 +00:00
|
|
|
BlockIO systemUnfreeze(const String & backup_name);
|
2022-06-08 12:09:59 +00:00
|
|
|
private:
|
2022-07-22 10:10:08 +00:00
|
|
|
ContextPtr local_context;
|
|
|
|
zkutil::ZooKeeperPtr zookeeper;
|
2022-06-08 12:09:59 +00:00
|
|
|
Poco::Logger * log = &Poco::Logger::get("Unfreezer");
|
|
|
|
static constexpr std::string_view backup_directory_prefix = "shadow";
|
2022-08-18 08:43:50 +00:00
|
|
|
static bool removeFreezedPart(DiskPtr disk, const String & path, const String & part_name, ContextPtr local_context, zkutil::ZooKeeperPtr zookeeper);
|
2022-06-08 12:09:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|