diff --git a/dbms/include/DB/Storages/StorageMergeTree.h b/dbms/include/DB/Storages/StorageMergeTree.h index 58a3ffef05b..055a1a3d604 100644 --- a/dbms/include/DB/Storages/StorageMergeTree.h +++ b/dbms/include/DB/Storages/StorageMergeTree.h @@ -119,9 +119,12 @@ private: MergeTreeDataWriter writer; MergeTreeDataMerger merger; - /// Для нумерации блоков. + /// For block numbers. SimpleIncrement increment; + /// For clearOldParts, clearOldTemporaryDirectories. + StopwatchWithLock time_after_previous_cleanup; + MergeTreeData::DataParts currently_merging; std::mutex currently_merging_mutex; diff --git a/dbms/src/Storages/StorageMergeTree.cpp b/dbms/src/Storages/StorageMergeTree.cpp index 83ad8df32d4..f178b1b6464 100644 --- a/dbms/src/Storages/StorageMergeTree.cpp +++ b/dbms/src/Storages/StorageMergeTree.cpp @@ -297,9 +297,12 @@ bool StorageMergeTree::merge( const String & partition, bool final) { - /// Удаляем старые куски. - data.clearOldParts(); - data.clearOldTemporaryDirectories(); /// TODO Делать это реже. + /// Clear old parts. It does not matter to do it more frequently than each second. + if (time_after_previous_cleanup.lockTestAndRestart(1)) + { + data.clearOldParts(); + data.clearOldTemporaryDirectories(); + } auto structure_lock = lockStructure(true);