Skip to content

Commit

Permalink
[branch-2.1]log more detail when query hits policy (#44685) (#45366)
Browse files Browse the repository at this point in the history
pick #44685
  • Loading branch information
wangbo authored Dec 13, 2024
1 parent 4d6d9a6 commit 384a1a4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion be/src/runtime/workload_management/workload_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void WorkloadActionCancelQuery::exec(WorkloadQueryInfo* query_info) {
std::stringstream msg;
msg << "query " << query_info->query_id
<< " cancelled by workload policy: " << query_info->policy_name
<< ", id:" << query_info->policy_id;
<< ", id:" << query_info->policy_id << ", " << query_info->cond_eval_msg;
std::string msg_str = msg.str();
LOG(INFO) << "[workload_schedule]" << msg_str;
ExecEnv::GetInstance()->fragment_mgr()->cancel_query(
Expand Down
20 changes: 20 additions & 0 deletions be/src/runtime/workload_management/workload_condition.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class WorkloadCondition {
virtual bool eval(std::string str_val) = 0;

virtual WorkloadMetricType get_workload_metric_type() = 0;

virtual std::string get_metric_string() = 0;

virtual std::string get_metric_value_string() = 0;
};

class WorkloadConditionQueryTime : public WorkloadCondition {
Expand All @@ -45,6 +49,10 @@ class WorkloadConditionQueryTime : public WorkloadCondition {
return WorkloadMetricType::QUERY_TIME;
}

std::string get_metric_string() override { return "query_time"; }

std::string get_metric_value_string() override { return std::to_string(_query_time); }

private:
int64_t _query_time;
WorkloadCompareOperator _op;
Expand All @@ -56,6 +64,10 @@ class WorkloadConditionScanRows : public WorkloadCondition {
bool eval(std::string str_val) override;
WorkloadMetricType get_workload_metric_type() override { return WorkloadMetricType::SCAN_ROWS; }

std::string get_metric_string() override { return "scan_rows"; }

std::string get_metric_value_string() override { return std::to_string(_scan_rows); }

private:
int64_t _scan_rows;
WorkloadCompareOperator _op;
Expand All @@ -69,6 +81,10 @@ class WorkloadConditionScanBytes : public WorkloadCondition {
return WorkloadMetricType::SCAN_BYTES;
}

std::string get_metric_string() override { return "scan_bytes"; }

std::string get_metric_value_string() override { return std::to_string(_scan_bytes); }

private:
int64_t _scan_bytes;
WorkloadCompareOperator _op;
Expand All @@ -82,6 +98,10 @@ class WorkloadConditionQueryMemory : public WorkloadCondition {
return WorkloadMetricType::QUERY_MEMORY_BYTES;
}

std::string get_metric_string() override { return "query_memory"; }

std::string get_metric_value_string() override { return std::to_string(_query_memory_bytes); }

private:
int64_t _query_memory_bytes;
WorkloadCompareOperator _op;
Expand Down
3 changes: 2 additions & 1 deletion be/src/runtime/workload_management/workload_query_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class WorkloadQueryInfo {
std::string query_id;
int64_t wg_id;
int64_t policy_id;
std::string policy_name;
std::string policy_name {""};
std::string cond_eval_msg {""};
};

} // namespace doris
5 changes: 5 additions & 0 deletions be/src/runtime/workload_management/workload_sched_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ bool WorkloadSchedPolicy::is_match(WorkloadQueryInfo* query_info_ptr) {
}

auto& metric_val_map = query_info_ptr->metric_map;
std::string cond_eval_msg = "";
for (auto& cond : _condition_list) {
if (metric_val_map.find(cond->get_workload_metric_type()) == metric_val_map.end()) {
return false;
Expand All @@ -69,7 +70,11 @@ bool WorkloadSchedPolicy::is_match(WorkloadQueryInfo* query_info_ptr) {
if (!cond->eval(val)) {
return false;
}
cond_eval_msg += cond->get_metric_string() + ":" + val + "(" +
cond->get_metric_value_string() + "), ";
}
cond_eval_msg = cond_eval_msg.substr(0, cond_eval_msg.size() - 2);
query_info_ptr->cond_eval_msg = cond_eval_msg;
return true;
}

Expand Down

0 comments on commit 384a1a4

Please sign in to comment.