[CP] fix plan feek back bug

This commit is contained in:
zzg19950727
2024-04-03 09:15:01 +00:00
committed by ob-robot
parent c7d582e4d7
commit c82292eb5f

View File

@ -1068,9 +1068,12 @@ int ObOperator::setup_op_feedback_info()
int64_t &total_db_time = fb_info.get_total_db_time();
total_db_time += op_monitor_info_.db_time_;
if (fb_node_idx_ >= 0 && fb_node_idx_ < nodes.count()) {
uint64_t cpu_khz = OBSERVER.get_cpu_frequency_khz();
ObExecFeedbackNode &node = nodes.at(fb_node_idx_);
node.block_time_ = op_monitor_info_.block_time_;
node.block_time_ /= cpu_khz;
node.db_time_ = op_monitor_info_.db_time_;
node.db_time_ /= cpu_khz;
node.op_close_time_ = op_monitor_info_.close_time_;
node.op_first_row_time_ = op_monitor_info_.first_row_time_;
node.op_last_row_time_ = op_monitor_info_.last_row_time_;
@ -1091,6 +1094,23 @@ int ObOperator::submit_op_monitor_node()
// Reference document:
op_monitor_info_.close_time_ = oceanbase::common::ObClockGenerator::getClock();
ObPlanMonitorNodeList *list = MTL(ObPlanMonitorNodeList*);
// exclude time cost in children, but px receive have no real children in exec view
int64_t db_time = total_time_; // use temp var to avoid dis-order close
if (!spec_.is_receive()) {
for (int64_t i = 0; i < child_cnt_; i++) {
db_time -= children_[i]->total_time_;
}
}
if (db_time < 0) {
db_time = 0;
}
// exclude io time cost
// Change to divide by cpu_khz when generating the virtual table.
// Otherwise, the unit of this field is inconsistent during SQL execution and after SQL execution is completed.
op_monitor_info_.db_time_ = 1000 * db_time;
op_monitor_info_.block_time_ = 1000 * op_monitor_info_.block_time_;
if (list && spec_.plan_) {
if (spec_.plan_->get_phy_plan_hint().monitor_
|| (ctx_.get_my_session()->is_user_session()
@ -1098,19 +1118,6 @@ int ObOperator::submit_op_monitor_node()
|| (op_monitor_info_.close_time_
- ctx_.get_plan_start_time()
> MONITOR_RUNNING_TIME_THRESHOLD)))) {
// exclude time cost in children, but px receive have no real children in exec view
uint64_t db_time = total_time_; // use temp var to avoid dis-order close
if (!spec_.is_receive()) {
for (int64_t i = 0; i < child_cnt_; i++) {
db_time -= children_[i]->total_time_;
}
}
// exclude io time cost
// Change to divide by cpu_khz when generating the virtual table.
// Otherwise, the unit of this field is inconsistent during SQL execution and after SQL execution is completed.
op_monitor_info_.db_time_ = 1000 * db_time;
op_monitor_info_.block_time_ = 1000 * op_monitor_info_.block_time_;
IGNORE_RETURN list->submit_node(op_monitor_info_);
LOG_DEBUG("debug monitor", K(spec_.id_));
}