diff --git a/be/src/runtime/workload_management/workload_action.cpp b/be/src/runtime/workload_management/workload_action.cpp index b36895594dcaad..e0d63f13395590 100644 --- a/be/src/runtime/workload_management/workload_action.cpp +++ b/be/src/runtime/workload_management/workload_action.cpp @@ -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( diff --git a/be/src/runtime/workload_management/workload_condition.h b/be/src/runtime/workload_management/workload_condition.h index a85268a8dc3a6a..cf53a5f07ddf9d 100644 --- a/be/src/runtime/workload_management/workload_condition.h +++ b/be/src/runtime/workload_management/workload_condition.h @@ -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 { @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/be/src/runtime/workload_management/workload_query_info.h b/be/src/runtime/workload_management/workload_query_info.h index e544668e1039ed..16151eec390746 100644 --- a/be/src/runtime/workload_management/workload_query_info.h +++ b/be/src/runtime/workload_management/workload_query_info.h @@ -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 \ No newline at end of file diff --git a/be/src/runtime/workload_management/workload_sched_policy.cpp b/be/src/runtime/workload_management/workload_sched_policy.cpp index efa8965dd77121..63b9362bc217be 100644 --- a/be/src/runtime/workload_management/workload_sched_policy.cpp +++ b/be/src/runtime/workload_management/workload_sched_policy.cpp @@ -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; @@ -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; }