This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 99e61379544 [fix] (compaction) fix compaction score in time series 
policy (#40242) (#40789)
99e61379544 is described below

commit 99e61379544cf6e1f7c2c44e13ef440e20a4ad4c
Author: Sun Chenyang <csun5...@gmail.com>
AuthorDate: Sun Sep 22 17:12:45 2024 +0800

    [fix] (compaction) fix compaction score in time series policy (#40242) 
(#40789)
---
 .../cumulative_compaction_time_series_policy.cpp   | 64 +---------------------
 ...mulative_compaction_time_series_policy_test.cpp |  2 +-
 2 files changed, 2 insertions(+), 64 deletions(-)

diff --git a/be/src/olap/cumulative_compaction_time_series_policy.cpp 
b/be/src/olap/cumulative_compaction_time_series_policy.cpp
index b1a8cddf20f..ad9d91c1d1c 100644
--- a/be/src/olap/cumulative_compaction_time_series_policy.cpp
+++ b/be/src/olap/cumulative_compaction_time_series_policy.cpp
@@ -28,14 +28,11 @@ namespace doris {
 
 uint32_t 
TimeSeriesCumulativeCompactionPolicy::calc_cumulative_compaction_score(Tablet* 
tablet) {
     uint32_t score = 0;
-    uint32_t level0_score = 0;
     bool base_rowset_exist = false;
     const int64_t point = tablet->cumulative_layer_point();
 
-    int64_t level0_total_size = 0;
     RowsetMetaSharedPtr first_meta;
     int64_t first_version = INT64_MAX;
-    std::list<RowsetMetaSharedPtr> checked_rs_metas;
     // NOTE: tablet._meta_lock is hold
     auto& rs_metas = tablet->tablet_meta()->all_rs_metas();
     // check the base rowset and collect the rowsets of cumulative part
@@ -54,12 +51,6 @@ uint32_t 
TimeSeriesCumulativeCompactionPolicy::calc_cumulative_compaction_score(
         } else {
             // collect the rowsets of cumulative part
             score += rs_meta->get_compaction_score();
-            if (rs_meta->compaction_level() == 0) {
-                level0_total_size += rs_meta->total_disk_size();
-                level0_score += rs_meta->get_compaction_score();
-            } else {
-                checked_rs_metas.push_back(rs_meta);
-            }
         }
     }
 
@@ -74,60 +65,7 @@ uint32_t 
TimeSeriesCumulativeCompactionPolicy::calc_cumulative_compaction_score(
         return 0;
     }
 
-    // Condition 1: the size of input files for compaction meets the 
requirement of parameter compaction_goal_size
-    int64_t compaction_goal_size_mbytes =
-            tablet->tablet_meta()->time_series_compaction_goal_size_mbytes();
-    if (level0_total_size >= compaction_goal_size_mbytes * 1024 * 1024) {
-        return score;
-    }
-
-    // Condition 2: the number of input files reaches the threshold specified 
by parameter compaction_file_count_threshold
-    if (level0_score >= 
tablet->tablet_meta()->time_series_compaction_file_count_threshold()) {
-        return score;
-    }
-
-    // Condition 3: level1 achieve compaction_goal_size
-    if (tablet->tablet_meta()->time_series_compaction_level_threshold() >= 2) {
-        checked_rs_metas.sort([](const RowsetMetaSharedPtr& a, const 
RowsetMetaSharedPtr& b) {
-            return a->version().first < b->version().first;
-        });
-        int32_t rs_meta_count = 0;
-        int64_t continuous_size = 0;
-        for (const auto& rs_meta : checked_rs_metas) {
-            rs_meta_count++;
-            continuous_size += rs_meta->total_disk_size();
-            if (rs_meta_count >= 2) {
-                if (continuous_size >= compaction_goal_size_mbytes * 1024 * 
1024) {
-                    return score;
-                }
-            }
-        }
-    }
-
-    int64_t now = UnixMillis();
-    int64_t last_cumu = tablet->last_cumu_compaction_success_time();
-    if (last_cumu != 0) {
-        int64_t cumu_interval = now - last_cumu;
-
-        // Condition 4: the time interval between compactions exceeds the 
value specified by parameter _compaction_time_threshold_second
-        if (cumu_interval >
-            
(tablet->tablet_meta()->time_series_compaction_time_threshold_seconds() * 
1000)) {
-            return score;
-        }
-    } else if (score > 0) {
-        // If the compaction process has not been successfully executed,
-        // the condition for triggering compaction based on the last 
successful compaction time (condition 3) will never be met
-        tablet->set_last_cumu_compaction_success_time(now);
-    }
-
-    // Condition 5: If there is a continuous set of empty rowsets, prioritize 
merging.
-    auto consecutive_empty_rowsets = 
tablet->pick_first_consecutive_empty_rowsets(
-            
tablet->tablet_meta()->time_series_compaction_empty_rowsets_threshold());
-    if (!consecutive_empty_rowsets.empty()) {
-        return score;
-    }
-
-    return 0;
+    return score;
 }
 
 void TimeSeriesCumulativeCompactionPolicy::calculate_cumulative_point(
diff --git a/be/test/olap/cumulative_compaction_time_series_policy_test.cpp 
b/be/test/olap/cumulative_compaction_time_series_policy_test.cpp
index 7c93d4d64b9..f96e801e1d3 100644
--- a/be/test/olap/cumulative_compaction_time_series_policy_test.cpp
+++ b/be/test/olap/cumulative_compaction_time_series_policy_test.cpp
@@ -393,7 +393,7 @@ TEST_F(TestTimeSeriesCumulativeCompactionPolicy, 
calc_cumulative_compaction_scor
     const uint32_t score = 
_tablet->calc_compaction_score(CompactionType::CUMULATIVE_COMPACTION,
                                                           
cumulative_compaction_policy);
 
-    EXPECT_EQ(0, score);
+    EXPECT_EQ(9, score);
 }
 
 TEST_F(TestTimeSeriesCumulativeCompactionPolicy, 
calc_cumulative_compaction_score_big_rowset) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to