From e0461cc7f48cd307bb079c8d5313ec926ffe7929 Mon Sep 17 00:00:00 2001 From: lichaoyong Date: Fri, 19 Jun 2020 11:22:06 +0800 Subject: [PATCH] [bug] Make compaction metrics value is right (#3903) Now _input_rowsets will be cleared when calling gc_used_rowsets(). After that, the metrics is not right upon be calculated. --- be/src/olap/base_compaction.cpp | 11 ++++++----- be/src/olap/cumulative_compaction.cpp | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/be/src/olap/base_compaction.cpp b/be/src/olap/base_compaction.cpp index e65a989cee39a5..24e90bf541da59 100644 --- a/be/src/olap/base_compaction.cpp +++ b/be/src/olap/base_compaction.cpp @@ -51,13 +51,14 @@ OLAPStatus BaseCompaction::compact() { // 3. set state to success _state = CompactionState::SUCCESS; - // 4. garbage collect input rowsets after base compaction - RETURN_NOT_OK(gc_unused_rowsets()); - TRACE("unused rowsets have been moved to GC queue"); - - // 5. add metric to base compaction + // 4. add metric to base compaction DorisMetrics::instance()->base_compaction_deltas_total.increment(_input_rowsets.size()); DorisMetrics::instance()->base_compaction_bytes_total.increment(_input_rowsets_size); + TRACE("save base compaction metrics"); + + // 5. garbage collect input rowsets after base compaction + RETURN_NOT_OK(gc_unused_rowsets()); + TRACE("unused rowsets have been moved to GC queue"); return OLAP_SUCCESS; } diff --git a/be/src/olap/cumulative_compaction.cpp b/be/src/olap/cumulative_compaction.cpp index f0a6bf27cc4609..5ab51ba35faad5 100755 --- a/be/src/olap/cumulative_compaction.cpp +++ b/be/src/olap/cumulative_compaction.cpp @@ -60,13 +60,14 @@ OLAPStatus CumulativeCompaction::compact() { // 5. set cumulative point _tablet->set_cumulative_layer_point(_input_rowsets.back()->end_version() + 1); - // 6. garbage collect input rowsets after cumulative compaction - RETURN_NOT_OK(gc_unused_rowsets()); - TRACE("unused rowsets have been moved to GC queue"); - - // 7. add metric to cumulative compaction + // 6. add metric to cumulative compaction DorisMetrics::instance()->cumulative_compaction_deltas_total.increment(_input_rowsets.size()); DorisMetrics::instance()->cumulative_compaction_bytes_total.increment(_input_rowsets_size); + TRACE("save cumulative compaction metrics"); + + // 7. garbage collect input rowsets after cumulative compaction + RETURN_NOT_OK(gc_unused_rowsets()); + TRACE("unused rowsets have been moved to GC queue"); return OLAP_SUCCESS; }