You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/06/28 03:55:14 UTC

[GitHub] [doris] yixiutt commented on a diff in pull request #10434: [Optimize](Compaction) compaction task producer add quiet period

yixiutt commented on code in PR #10434:
URL: https://github.com/apache/doris/pull/10434#discussion_r908005218


##########
be/src/olap/data_dir.h:
##########
@@ -139,6 +139,41 @@ class DataDir {
     // storage_root/trash/20150619154308.delete_counter/tablet_path/segment_path/tablet_uid
     Status move_to_trash(const FilePathDesc& segment_path_desc);
 
+    // add data_dir consecutive prepared failed times to make it
+    // goes to quiet period to save cpu cost when no tablet needs to compact
+    void set_tablet_prepare_compact_failed(int64_t now, bool failed) {
+        std::unique_lock<std::mutex> lck(_compaction_quiet_mutex);
+        if (!failed) {
+            _compaction_last_prepared_failed_ts = 0;
+            _compaction_quiet_period_s = 0;
+            _compaction_sleep_cv.notify_one();
+        } else {
+            if (_compaction_last_prepared_failed_ts == 0) {
+                _compaction_last_prepared_failed_ts = now;
+                return;
+            }
+            if (_compaction_last_prepared_failed_ts != 0 &&
+                now - _compaction_last_prepared_failed_ts >=
+                        config::max_prepare_failure_interval_before_quiet) {
+                _compaction_quiet_period_s = now + config::data_dir_quiet_period_s;
+                _compaction_last_prepared_failed_ts = 0;
+            }
+        }
+    }
+    void wait_in_quiet_period(int64_t wait_ms) {
+        std::unique_lock<std::mutex> lock(_compaction_quiet_mutex);
+        // It is necessary to wake up the thread on timeout to prevent deadlock
+        // in case of no running compaction task.
+        _compaction_sleep_cv.wait_for(lock, std::chrono::milliseconds(wait_ms),
+                                      [=] { return _compaction_quiet_period_s == 0; });

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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