#pragma once #include #include #include #include #include namespace DB { class StorageReplicatedMergeTree; /** Removes obsolete data from a table of type ReplicatedMergeTree. */ class ReplicatedMergeTreeCleanupThread { public: ReplicatedMergeTreeCleanupThread(StorageReplicatedMergeTree & storage_); ~ReplicatedMergeTreeCleanupThread(); private: StorageReplicatedMergeTree & storage; Logger * log; std::thread thread; void run(); void iterate(); /// Remove old records from ZooKeeper. void clearOldLogs(); /// Remove old block hashes from ZooKeeper. This is done by the leader replica. void clearOldBlocks(); using NodeCTimeCache = std::map; NodeCTimeCache cached_block_stats; struct NodeWithStat; /// Returns list of blocks (with their stat) sorted by ctime in descending order. void getBlocksSortedByTime(zkutil::ZooKeeper & zookeeper, std::vector & timed_blocks); /// TODO Removing old quorum/failed_parts /// TODO Removing old nonincrement_block_numbers }; }