bobhan1 commented on code in PR #56737:
URL: https://github.com/apache/doris/pull/56737#discussion_r2418735130
##########
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
+ if (source == WarmUpTriggerSource::JOB) {
+ if (existing_state.trigger_source == WarmUpTriggerSource::JOB) {
+ // Same job type already in progress, skip to avoid duplicate
warmup
+ return false;
+ }
+ // Override other states (EVENT_DRIVEN, SYNC_ROWSET) but not
another JOB
+ } else {
+ // For non-job warmup (EVENT_DRIVEN, SYNC_ROWSET), skip if any
warmup exists
+ return false;
+ }
}
- if (state == WarmUpState::TRIGGERED_BY_JOB) {
+
+ if (source == WarmUpTriggerSource::JOB) {
g_file_cache_warm_up_rowset_triggered_by_job_num << 1;
- } else if (state == WarmUpState::TRIGGERED_BY_SYNC_ROWSET) {
+ } else if (source == WarmUpTriggerSource::SYNC_ROWSET) {
g_file_cache_warm_up_rowset_triggered_by_sync_rowset_num << 1;
+ } else if (source == WarmUpTriggerSource::EVENT_DRIVEN) {
+ g_file_cache_warm_up_rowset_triggered_by_event_driven_num << 1;
}
- _rowset_warm_up_states[rowset.rowset_id()] = {
- .state = state, .num_segments = rowset.num_segments(), .start_tp =
start_tp};
+ _rowset_warm_up_states[rowset_id] = {
Review Comment:
only one trigger source can update a rowset's state in any time
--
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]