luwei16 commented on code in PR #49882:
URL: https://github.com/apache/doris/pull/49882#discussion_r2036920080


##########
be/src/cloud/cloud_storage_engine.cpp:
##########
@@ -585,6 +593,64 @@ std::vector<CloudTabletSPtr> 
CloudStorageEngine::_generate_cloud_compaction_task
     return tablets_compaction;
 }
 
+Status CloudStorageEngine::_prepare_tablet_compaction_job(
+        ReaderType compaction_type, const CloudTabletSPtr& tablet,
+        std::shared_ptr<CloudCompactionMixin> compaction) {
+    if (compaction_type == ReaderType::READER_CUMULATIVE_COMPACTION) {
+        auto cumu_compaction = 
static_pointer_cast<CloudCumulativeCompaction>(compaction);
+        auto st = cumu_compaction->prepare_compact();
+        if (!st.ok()) {
+            if ((!st.is<ErrorCode::CUMULATIVE_NO_SUITABLE_VERSION>()) || 
VLOG_DEBUG_IS_ON) {
+                LOG(WARNING) << "failed to submit cumulative compaction task 
for tablet: "
+                             << tablet->tablet_id() << ", err: " << st;
+            }
+            long now = duration_cast<std::chrono::milliseconds>(
+                               
std::chrono::system_clock::now().time_since_epoch())
+                               .count();
+            if (st.is<ErrorCode::CUMULATIVE_NO_SUITABLE_VERSION>() &&
+                st.msg() != "_last_delete_version.first not equal to -1") {
+                // Backoff strategy if no suitable version
+                tablet->last_cumu_no_suitable_version_ms = now;
+            }
+            tablet->set_last_cumu_compaction_failure_time(now);
+            std::lock_guard lock(_compaction_mtx);
+            _tablet_preparing_cumu_compaction.erase(tablet->tablet_id());
+            return st;
+        }
+        {
+            std::lock_guard lock(_compaction_mtx);
+            _tablet_preparing_cumu_compaction.erase(tablet->tablet_id());
+            
_submitted_cumu_compactions[tablet->tablet_id()].push_back(cumu_compaction);
+        }
+        return st;
+    } else if (compaction_type == ReaderType::READER_BASE_COMPACTION) {
+        auto base_compaction = 
static_pointer_cast<CloudBaseCompaction>(compaction);
+        auto st = base_compaction->prepare_compact();
+        if (!st.ok()) {
+            if ((!st.is<ErrorCode::BE_NO_SUITABLE_VERSION>()) || 
VLOG_DEBUG_IS_ON) {
+                LOG(WARNING) << "failed to submit base compaction task for 
tablet: "
+                             << tablet->tablet_id() << ", err: " << st;
+            }
+            long now = duration_cast<std::chrono::milliseconds>(
+                               
std::chrono::system_clock::now().time_since_epoch())
+                               .count();
+            tablet->set_last_base_compaction_failure_time(now);
+            std::lock_guard lock(_compaction_mtx);
+            _submitted_base_compactions.erase(tablet->tablet_id());

Review Comment:
   Don't change the meaning of _submitted_base_compactions



-- 
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-unsubscr...@doris.apache.org

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


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

Reply via email to