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

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new f90d844a53 [improvement](compaction) enable compaction in 
TABLET_NOTREADY (#16470)
f90d844a53 is described below

commit f90d844a530bb384c6a31e60c62647b3a4e7fe75
Author: yixiutt <102007456+yixi...@users.noreply.github.com>
AuthorDate: Tue Feb 7 19:58:23 2023 +0800

    [improvement](compaction) enable compaction in TABLET_NOTREADY (#16470)
    
    If alter task in queue, compaction is not enabled and may cause too much 
version.
    Keep last 10 version in new tablet so that base tablet's max version will
    not be merged and than we can copy data from base tablet to new tablet.
---
 be/src/olap/cumulative_compaction_policy.cpp | 8 ++++++++
 be/src/olap/tablet.cpp                       | 7 +++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/be/src/olap/cumulative_compaction_policy.cpp 
b/be/src/olap/cumulative_compaction_policy.cpp
index 76775485b5..c2735def03 100644
--- a/be/src/olap/cumulative_compaction_policy.cpp
+++ b/be/src/olap/cumulative_compaction_policy.cpp
@@ -232,6 +232,7 @@ int SizeBasedCumulativeCompactionPolicy::pick_input_rowsets(
         std::vector<RowsetSharedPtr>* input_rowsets, Version* 
last_delete_version,
         size_t* compaction_score) {
     size_t promotion_size = tablet->cumulative_promotion_size();
+    auto max_version = tablet->max_version().first;
     int transient_size = 0;
     *compaction_score = 0;
     int64_t total_size = 0;
@@ -251,6 +252,13 @@ int 
SizeBasedCumulativeCompactionPolicy::pick_input_rowsets(
                 continue;
             }
         }
+        if (tablet->tablet_state() == TABLET_NOTREADY) {
+            // If tablet under alter, keep latest 10 version so that base 
tablet max version
+            // not merged in new tablet, and then we can copy data from base 
tablet
+            if (rowset->version().second < max_version - 10) {
+                continue;
+            }
+        }
         if (*compaction_score >= max_compaction_score) {
             // got enough segments
             break;
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index 3cb4079159..009513748f 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -828,10 +828,9 @@ bool Tablet::can_do_compaction(size_t path_hash, 
CompactionType compaction_type)
     }
 
     if (tablet_state() == TABLET_NOTREADY) {
-        // Before doing schema change, tablet's rowsets that versions smaller 
than max converting version will be
-        // removed. So, we only need to do the compaction when it is being 
converted.
-        // After being converted, tablet's state will be changed to 
TABLET_RUNNING.
-        return SchemaChangeHandler::tablet_in_converting(tablet_id());
+        // In TABLET_NOTREADY, we keep last 10 versions in new tablet so base 
tablet max_version
+        // not merged in new tablet and then we can do compaction
+        return true;
     }
 
     return true;


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

Reply via email to