github-actions[bot] commented on code in PR #62891:
URL: https://github.com/apache/doris/pull/62891#discussion_r3178059768
##########
be/src/exec/pipeline/pipeline_task.cpp:
##########
@@ -1076,12 +1085,18 @@ void PipelineTask::wake_up(Dependency* dep,
std::unique_lock<std::mutex>& /* dep
Status PipelineTask::_state_transition(State new_state) {
const auto& table =
_wake_up_early ? WAKE_UP_EARLY_LEGAL_STATE_TRANSITION :
LEGAL_STATE_TRANSITION;
- if (!table[(int)new_state].contains(_exec_state)) {
+ auto current_state = _exec_state.load();
+ if (!table[(int)new_state].contains(current_state)) {
Review Comment:
This still leaves a race where a delayed `wake_up()` can overwrite a
terminal state. `wake_up()` is not protected by `_dependency_lifecycle_lock`
unless it is synchronously invoked from `unblock_all_dependencies()`: a normal
`Dependency::set_ready()` can call it from another thread. In
`_state_transition(RUNNABLE)`, that thread can load `BLOCKED` here and pass
validation, then `close()`/`finalize()` can take the lifecycle lock, publish
`FINISHED`/`FINALIZED`, and clear `_sink`/`_operators`; after that this same
`_state_transition()` can continue with `need_move == true` (computed before
the terminal transition) and store `_exec_state = RUNNABLE`. `wake_up()` then
sees a non-terminal state and resubmits a task whose resources have already
been released, which is the crash this PR is trying to prevent. Please make the
read/check/write of `_exec_state` atomic with respect to concurrent terminal
transitions, for example by restoring a CAS/retry transition or by using one
lock for ever
y `_state_transition()` caller that can race with `wake_up()`.
--
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]