ClickHouse/dbms/src/Storages/MergeTree/ReplicatedMergeTreeAlterThread.h
Alexey Zatelepin cc7950a733 don't destroy Cleanup- and AlterThread objects, just deactivate the tasks [#CLICKHOUSE-3862]
Otherwise segfaults are possible when the objects are recreated in the middle of the queue task execution.
2018-07-30 21:47:24 +03:00

44 lines
855 B
C++

#pragma once
#include <thread>
#include <Common/BackgroundSchedulePool.h>
#include <Common/ZooKeeper/Types.h>
#include <Core/Types.h>
#include <common/logger_useful.h>
namespace DB
{
class StorageReplicatedMergeTree;
/** Keeps track of changing the table structure in ZooKeeper and performs the necessary conversions.
*
* NOTE This has nothing to do with manipulating partitions,
* which are processed through the replication queue.
*/
class ReplicatedMergeTreeAlterThread
{
public:
ReplicatedMergeTreeAlterThread(StorageReplicatedMergeTree & storage_);
void start()
{
task->activate();
task->schedule();
}
void stop() { task->deactivate(); }
private:
void run();
StorageReplicatedMergeTree & storage;
String log_name;
Logger * log;
BackgroundSchedulePool::TaskHolder task;
};
}