3333
3434#include " common/logging.h"
3535#include " pipeline/pipeline_task.h"
36- #include " pipeline/task_queue.h"
3736#include " pipeline_fragment_context.h"
3837#include " runtime/exec_env.h"
3938#include " runtime/query_context.h"
@@ -103,6 +102,9 @@ void TaskScheduler::_do_work(int index) {
103102 if (!task) {
104103 continue ;
105104 }
105+ // The task is already running, maybe block in now dependency wake up by other thread
106+ // but the block thread still hold the task, so put it back to the queue, until the hold
107+ // thread set task->set_running(false)
106108 if (task->is_running ()) {
107109 static_cast <void >(_task_queue.push_back (task, index));
108110 continue ;
@@ -129,12 +131,8 @@ void TaskScheduler::_do_work(int index) {
129131 // task exec
130132 bool eos = false ;
131133 auto status = Status::OK ();
134+ task->set_core_id (index);
132135
133- #ifdef __APPLE__
134- uint32_t core_id = 0 ;
135- #else
136- uint32_t core_id = sched_getcpu ();
137- #endif
138136 ASSIGN_STATUS_IF_CATCH_EXCEPTION (
139137 // TODO: use a better enclose to abstracting these
140138 if (ExecEnv::GetInstance ()->pipeline_tracer_context ()->enabled ()) {
@@ -149,12 +147,11 @@ void TaskScheduler::_do_work(int index) {
149147
150148 uint64_t end_time = MonotonicMicros ();
151149 ExecEnv::GetInstance ()->pipeline_tracer_context ()->record (
152- {query_id, task_name, core_id, thread_id, start_time, end_time});
150+ {query_id, task_name, static_cast <uint32_t >(index), thread_id,
151+ start_time, end_time});
153152 } else { status = task->execute (&eos); },
154153 status);
155154
156- task->set_previous_core_id (index);
157-
158155 if (!status.ok ()) {
159156 // Print detail informations below when you debugging here.
160157 //
@@ -173,14 +170,11 @@ void TaskScheduler::_do_work(int index) {
173170 if (eos) {
174171 // is pending finish will add the task to dependency's blocking queue, and then the task will be
175172 // added to running queue when dependency is ready.
176- if (task->is_pending_finish ()) {
177- // Only meet eos, should set task to PENDING_FINISH state
178- task->set_running (false );
179- } else {
173+ if (!task->is_pending_finish ()) {
180174 Status exec_status = fragment_ctx->get_query_ctx ()->exec_status ();
181175 _close_task (task, exec_status);
176+ continue ;
182177 }
183- continue ;
184178 }
185179
186180 task->set_running (false );
0 commit comments