Copilot commented on code in PR #62155:
URL: https://github.com/apache/doris/pull/62155#discussion_r3043029542


##########
be/test/exec/pipeline/dummy_task_queue.h:
##########
@@ -53,7 +53,10 @@ class MockTaskScheduler : public TaskScheduler {
 public:
     MockTaskScheduler() : TaskScheduler() { _task_queue = 
std::make_unique<DummyTaskQueue>(1); }
 
-    Status submit(PipelineTaskSPtr task) override { return 
_task_queue->push_back(task); }
+    Status submit(PipelineTaskSPtr task) override {
+        _submit_count++;
+        return _task_queue->push_back(task);
+    }

Review Comment:
   `MockTaskScheduler::submit()` increments `_submit_count` without 
synchronization. `submit()` can be called from different threads in several 
pipeline tests (e.g., wakeups triggered by background threads), so this 
introduces a data race/UB in the test code. Make `_submit_count` an 
`std::atomic<int>` (or protect it with a mutex) and update the 
increment/accessors accordingly.



##########
be/src/exec/pipeline/pipeline_task.cpp:
##########
@@ -1050,6 +1050,13 @@ Status PipelineTask::wake_up(Dependency* dep, 
std::unique_lock<std::mutex>& /* d
     _blocked_dep = nullptr;
     auto holder = std::dynamic_pointer_cast<PipelineTask>(shared_from_this());
     RETURN_IF_ERROR(_state_transition(PipelineTask::State::RUNNABLE));
+    // When _wake_up_early is set, FINISHED/FINALIZED → RUNNABLE is a legal 
no-op
+    // (state stays unchanged). We must not resubmit a terminated task to the 
scheduler
+    // because finalize() has already cleared _sink/_operators, and submit() 
would
+    // dereference them (e.g. via is_blockable()) causing a SIGSEGV.
+    if (_exec_state == State::FINISHED || _exec_state == State::FINALIZED) {
+        return Status::OK();
+    }

Review Comment:
   In the FINISHED/FINALIZED delayed-wake_up case, 
`_state_transition(RUNNABLE)` is a no-op but it still updates the runtime 
profile's `TaskState` info string to `RUNNABLE`. With the new early-return, the 
task stays FINISHED/FINALIZED while the profile may now incorrectly report 
RUNNABLE, which can make debugging misleading. Consider checking 
`_wake_up_early && (_exec_state==FINISHED||FINALIZED)` before calling 
`_state_transition()`, or adjust `_state_transition()` to only update 
`TaskState` when the state actually changes.
   ```suggestion
       // When _wake_up_early is set, FINISHED/FINALIZED → RUNNABLE is a legal 
no-op
       // (state stays unchanged). We must not call _state_transition(RUNNABLE) 
here,
       // because that can still update the runtime profile TaskState to 
RUNNABLE even
       // though the task remains terminated, which is misleading during 
debugging.
       // We also must not resubmit a terminated task to the scheduler because
       // finalize() has already cleared _sink/_operators, and submit() would
       // dereference them (e.g. via is_blockable()) causing a SIGSEGV.
       if (_exec_state == State::FINISHED || _exec_state == State::FINALIZED) {
           return Status::OK();
       }
       RETURN_IF_ERROR(_state_transition(PipelineTask::State::RUNNABLE));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to