freemandealer commented on code in PR #56737:
URL: https://github.com/apache/doris/pull/56737#discussion_r2418630843


##########
be/src/cloud/cloud_tablet.cpp:
##########
@@ -1647,51 +1649,101 @@ Status CloudTablet::check_delete_bitmap_cache(int64_t 
txn_id,
 WarmUpState CloudTablet::get_rowset_warmup_state(RowsetId rowset_id) {
     std::shared_lock rlock(_meta_lock);
     if (!_rowset_warm_up_states.contains(rowset_id)) {
-        return WarmUpState::NONE;
+        return {.trigger_source = WarmUpTriggerSource::NONE, .progress = 
WarmUpProgress::NONE};
     }
-    return _rowset_warm_up_states[rowset_id].state;
+    auto& warmup_info = _rowset_warm_up_states[rowset_id];
+    warmup_info.update_state();
+    return warmup_info.state;
 }
 
-bool CloudTablet::add_rowset_warmup_state(const RowsetMeta& rowset, 
WarmUpState state,
+bool CloudTablet::add_rowset_warmup_state(const RowsetMeta& rowset, 
WarmUpTriggerSource source,
                                           
std::chrono::steady_clock::time_point start_tp) {
     std::lock_guard wlock(_meta_lock);
-    return add_rowset_warmup_state_unlocked(rowset, state, start_tp);
+    return add_rowset_warmup_state_unlocked(rowset, source, start_tp);
 }
 
-void CloudTablet::update_rowset_warmup_state_inverted_idx_num(RowsetId 
rowset_id, int64_t delta) {
+bool 
CloudTablet::update_rowset_warmup_state_inverted_idx_num(WarmUpTriggerSource 
source,
+                                                              RowsetId 
rowset_id, int64_t delta) {
     std::lock_guard wlock(_meta_lock);
-    update_rowset_warmup_state_inverted_idx_num_unlocked(rowset_id, delta);
+    return update_rowset_warmup_state_inverted_idx_num_unlocked(source, 
rowset_id, delta);
 }
 
-void 
CloudTablet::update_rowset_warmup_state_inverted_idx_num_unlocked(RowsetId 
rowset_id,
+bool 
CloudTablet::update_rowset_warmup_state_inverted_idx_num_unlocked(WarmUpTriggerSource
 source,
+                                                                       
RowsetId rowset_id,
                                                                        int64_t 
delta) {
-    if (!_rowset_warm_up_states.contains(rowset_id)) {
-        return;
+    auto it = _rowset_warm_up_states.find(rowset_id);
+    if (it == _rowset_warm_up_states.end()) {
+        return false;
+    }
+    if (it->second.state.trigger_source != source) {
+        // Only the same trigger source can update the state
+        return false;
     }
-    _rowset_warm_up_states[rowset_id].num_inverted_idx += delta;
+    it->second.num_inverted_idx += delta;
+    return true;
 }
 
-bool CloudTablet::add_rowset_warmup_state_unlocked(const RowsetMeta& rowset, 
WarmUpState state,
+bool CloudTablet::add_rowset_warmup_state_unlocked(const RowsetMeta& rowset,
+                                                   WarmUpTriggerSource source,
                                                    
std::chrono::steady_clock::time_point start_tp) {
-    if (_rowset_warm_up_states.contains(rowset.rowset_id())) {
-        return false;
+    auto rowset_id = rowset.rowset_id();
+
+    // Check if rowset already has warmup state
+    if (_rowset_warm_up_states.contains(rowset_id)) {
+        auto existing_state = _rowset_warm_up_states[rowset_id].state;
+
+        // For job-triggered warmup (one-time and periodic warmup), allow it 
to proceed
+        // except when there's already another job-triggered warmup in progress

Review Comment:
   what if the job-triigered warmup is done? still return false?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to