diff --git a/be/src/runtime/plan_fragment_executor.cpp b/be/src/runtime/plan_fragment_executor.cpp index 9d06282e534974..61b84a43256be4 100644 --- a/be/src/runtime/plan_fragment_executor.cpp +++ b/be/src/runtime/plan_fragment_executor.cpp @@ -487,21 +487,22 @@ Status PlanFragmentExecutor::get_next_internal(RowBatch** batch) { return Status::OK(); } -void PlanFragmentExecutor::update_status(const Status& status) { - if (status.ok()) { +void PlanFragmentExecutor::update_status(const Status& new_status) { + if (new_status.ok()) { return; } { boost::lock_guard l(_status_lock); - if (!_status.ok()) { - if (status.is_mem_limit_exceeded()) { - _runtime_state->set_mem_limit_exceeded(status.get_error_msg()); + // if current `_status` is ok, set it to `new_status` to record the error. + if (_status.ok()) { + if (new_status.is_mem_limit_exceeded()) { + _runtime_state->set_mem_limit_exceeded(new_status.get_error_msg()); } - _status = status; + _status = new_status; if (_runtime_state->query_options().query_type == TQueryType::EXTERNAL) { TUniqueId fragment_instance_id = _runtime_state->fragment_instance_id(); - _exec_env->result_queue_mgr()->update_queue_status(fragment_instance_id, status); + _exec_env->result_queue_mgr()->update_queue_status(fragment_instance_id, new_status); } } }