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

commit 67a09d14c61b69ddafc4153a943f814ca8a21764
Author: Chenyang Sun <csun5...@gmail.com>
AuthorDate: Fri Jul 28 23:07:36 2023 +0800

    [fix](compaction) fix time series compaction policy corner case (#22238)
---
 be/src/olap/cumulative_compaction_time_series_policy.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/be/src/olap/cumulative_compaction_time_series_policy.cpp 
b/be/src/olap/cumulative_compaction_time_series_policy.cpp
index 7734ba7fc4..ac816d0e54 100644
--- a/be/src/olap/cumulative_compaction_time_series_policy.cpp
+++ b/be/src/olap/cumulative_compaction_time_series_policy.cpp
@@ -82,6 +82,10 @@ uint32_t 
TimeSeriesCumulativeCompactionPolicy::calc_cumulative_compaction_score(
         if (cumu_interval > 
(config::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);
     }
 
     return 0;
@@ -164,7 +168,14 @@ int 
TimeSeriesCumulativeCompactionPolicy::pick_input_rowsets(
     input_rowsets->clear();
     int64_t total_size = 0;
 
-    for (auto& rowset : candidate_rowsets) {
+    // when single replica compaction is enabled and BE1 fetchs merged rowsets 
from BE2, and then BE2 goes offline.
+    // BE1 should performs compaction on its own, the time series compaction 
may re-compact previously fetched rowsets.
+    // time series compaction policy needs to skip over the fetched rowset
+    const auto& first_rowset_iter = std::find_if(
+            candidate_rowsets.begin(), candidate_rowsets.end(),
+            [](const RowsetSharedPtr& rs) { return rs->start_version() == 
rs->end_version(); });
+    for (auto it = first_rowset_iter; it != candidate_rowsets.end(); ++it) {
+        const auto& rowset = *it;
         // check whether this rowset is delete version
         if (rowset->rowset_meta()->has_delete_predicate()) {
             *last_delete_version = rowset->version();


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

Reply via email to