mrhhsg opened a new pull request, #71390:
URL: https://github.com/apache/doris/pull/71390

   ### What problem does this PR solve?
   
   Issue Number: None
   
   Related PR: #69208
   
   Cherry-picked from #69208.
   
   Problem Summary: The background cancel worker calls 
`PipelineTask::stop_if_finished()`, which previously copied `_sink` without 
synchronization while a scheduler worker could reset the same shared_ptr in 
`finalize()`. Concurrent access to that shared_ptr instance is a data race.
   
   This backport protects the finalized-state check and `_sink` snapshot with 
branch-4.1's `_dependency_lock`, the same mutex used for the reset in 
`finalize()`. The local shared_ptr retains the sink for the subsequent finished 
check. The lock is released before calling `terminate()`, which acquires that 
mutex itself.
   
   Conflict resolution uses the existing branch-4.1 `_dependency_lock` and 
`terminate()` interfaces instead of importing the master lifecycle/scheduler 
refactoring. The upstream lifecycle-exclusion unit test is preserved in full.
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test:
       - [x] Unit Test
           - ASAN build and `./run-be-ut.sh --run --filter='PipelineTaskTest.*' 
-j 48`: **23/23 passed**.
           - `GTEST_REPEAT=200 ./run-be-ut.sh --run 
--filter='PipelineTaskTest.TEST_STOP_IF_FINISHED_EXCLUDES_FINALIZE' -j 48`: 
**200/200 passed**.
           - clang-format 16 checked both changed C++ files; `git diff --check` 
passed for the complete backport diff.
       - SQL regression tests were not run; the focused C++ unit test covers 
lifecycle synchronization and the finalized-task path.
   - Behavior changed:
       - [x] No intended SQL behavior change; this synchronizes existing task 
lifecycle operations.
   - Does this need documentation?
       - [x] No.


-- 
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