From 1065ddef651e5dcb019e33694631bc6bbf83dcb1 Mon Sep 17 00:00:00 2001 From: roverxu Date: Wed, 16 Dec 2020 22:02:34 +0800 Subject: [PATCH] fix bug when drop data --- src/Storages/MergeTree/MergeTreeData.cpp | 6 +++--- .../0_stateless/01600_count_of_parts_metrics.reference | 0 tests/queries/0_stateless/01600_count_of_parts_metrics.sql | 0 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 tests/queries/0_stateless/01600_count_of_parts_metrics.reference create mode 100644 tests/queries/0_stateless/01600_count_of_parts_metrics.sql diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index af3e323763e..ef5c5712b3a 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -1282,13 +1282,13 @@ void MergeTreeData::dropAllData() DataPartsVector all_parts(data_parts_by_info.begin(), data_parts_by_info.end()); DataPartsVector committed_parts = getDataPartsVector({DataPartState::Committed}); - data_parts_indexes.clear(); - column_sizes.clear(); - CurrentMetrics::sub(CurrentMetrics::Parts, all_parts.size()); CurrentMetrics::sub(CurrentMetrics::PartsActive, committed_parts.size()); CurrentMetrics::sub(CurrentMetrics::PartsInactive, all_parts.size() - committed_parts.size()); + data_parts_indexes.clear(); + column_sizes.clear(); + /// Tables in atomic databases have UUID and stored in persistent locations. /// No need to drop caches (that are keyed by filesystem path) because collision is not possible. if (!getStorageID().hasUUID()) diff --git a/tests/queries/0_stateless/01600_count_of_parts_metrics.reference b/tests/queries/0_stateless/01600_count_of_parts_metrics.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01600_count_of_parts_metrics.sql b/tests/queries/0_stateless/01600_count_of_parts_metrics.sql new file mode 100644 index 00000000000..e69de29bb2d