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

zhangchen 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 3e83fb87292 [enhancement](compaction) record base compaction schedule 
time and status (#25283)
3e83fb87292 is described below

commit 3e83fb872920fff8272775c305c64eb59f92ccab
Author: huanghaibin <284824...@qq.com>
AuthorDate: Fri Oct 13 19:51:55 2023 +0800

    [enhancement](compaction) record base compaction schedule time and status 
(#25283)
---
 be/src/olap/olap_server.cpp |  3 +++
 be/src/olap/tablet.cpp      | 11 +++++++++++
 be/src/olap/tablet.h        | 14 ++++++++++++++
 3 files changed, 28 insertions(+)

diff --git a/be/src/olap/olap_server.cpp b/be/src/olap/olap_server.cpp
index 4388ac92468..de2c61ea7cc 100644
--- a/be/src/olap/olap_server.cpp
+++ b/be/src/olap/olap_server.cpp
@@ -625,6 +625,9 @@ void StorageEngine::_compaction_tasks_producer_callback() {
             /// If it is not cleaned up, the reference count of the tablet 
will always be greater than 1,
             /// thus cannot be collected by the garbage collector. 
(TabletManager::start_trash_sweep)
             for (const auto& tablet : tablets_compaction) {
+                if (compaction_type == CompactionType::BASE_COMPACTION) {
+                    
tablet->set_last_base_compaction_schedule_time(UnixMillis());
+                }
                 Status st = _submit_compaction_task(tablet, compaction_type, 
false);
                 if (!st.ok()) {
                     LOG(WARNING) << "failed to submit compaction task for 
tablet: "
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index 90ee40635ca..a4acaa3ee69 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -1443,6 +1443,15 @@ void Tablet::get_compaction_status(std::string* 
json_result) {
     format_str = 
ToStringFromUnixMillis(_last_full_compaction_success_millis.load());
     full_success_value.SetString(format_str.c_str(), format_str.length(), 
root.GetAllocator());
     root.AddMember("last full success time", full_success_value, 
root.GetAllocator());
+    rapidjson::Value base_schedule_value;
+    format_str = 
ToStringFromUnixMillis(_last_base_compaction_schedule_millis.load());
+    base_schedule_value.SetString(format_str.c_str(), format_str.length(), 
root.GetAllocator());
+    root.AddMember("last base schedule time", base_schedule_value, 
root.GetAllocator());
+    rapidjson::Value base_compaction_status_value;
+    
base_compaction_status_value.SetString(_last_base_compaction_status.c_str(),
+                                           
_last_base_compaction_status.length(),
+                                           root.GetAllocator());
+    root.AddMember("last base status", base_compaction_status_value, 
root.GetAllocator());
 
     // print all rowsets' version as an array
     rapidjson::Document versions_arr;
@@ -1760,6 +1769,7 @@ Status 
Tablet::prepare_compaction_and_calculate_permits(CompactionType compactio
         StorageEngine::instance()->create_base_compaction(tablet, 
_base_compaction);
         DorisMetrics::instance()->base_compaction_request_total->increment(1);
         Status res = _base_compaction->prepare_compact();
+        set_last_base_compaction_status(res.to_string());
         if (!res.ok()) {
             set_last_base_compaction_failure_time(UnixMillis());
             *permits = 0;
@@ -1897,6 +1907,7 @@ void Tablet::execute_compaction(CompactionType 
compaction_type) {
         });
 
         Status res = _base_compaction->execute_compact();
+        set_last_base_compaction_status(res.to_string());
         if (!res.ok()) {
             set_last_base_compaction_failure_time(UnixMillis());
             
DorisMetrics::instance()->base_compaction_request_failed->increment(1);
diff --git a/be/src/olap/tablet.h b/be/src/olap/tablet.h
index 43993773542..c7e7dcc6e31 100644
--- a/be/src/olap/tablet.h
+++ b/be/src/olap/tablet.h
@@ -253,6 +253,11 @@ public:
         _last_full_compaction_success_millis = millis;
     }
 
+    int64_t last_base_compaction_schedule_time() { return 
_last_base_compaction_schedule_millis; }
+    void set_last_base_compaction_schedule_time(int64_t millis) {
+        _last_base_compaction_schedule_millis = millis;
+    }
+
     void delete_all_files();
 
     void check_tablet_path_exists();
@@ -322,6 +327,12 @@ public:
         return _cumulative_compaction_policy;
     }
 
+    void set_last_base_compaction_status(std::string status) {
+        _last_base_compaction_status = status;
+    }
+
+    std::string get_last_base_compaction_status() { return 
_last_base_compaction_status; }
+
     inline bool all_beta() const {
         std::shared_lock rdlock(_meta_lock);
         return _tablet_meta->all_beta();
@@ -656,10 +667,13 @@ private:
     std::atomic<int64_t> _last_base_compaction_success_millis;
     // timestamp of last full compaction success
     std::atomic<int64_t> _last_full_compaction_success_millis;
+    // timestamp of last base compaction schedule time
+    std::atomic<int64_t> _last_base_compaction_schedule_millis;
     std::atomic<int64_t> _cumulative_point;
     std::atomic<int64_t> _cumulative_promotion_size;
     std::atomic<int32_t> _newly_created_rowset_num;
     std::atomic<int64_t> _last_checkpoint_time;
+    std::string _last_base_compaction_status;
 
     // cumulative compaction policy
     std::shared_ptr<CumulativeCompactionPolicy> _cumulative_compaction_policy;


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

Reply via email to