github-actions[bot] commented on code in PR #67261:
URL: https://github.com/apache/doris/pull/67261#discussion_r3878115689


##########
be/src/exec/pipeline/pipeline_fragment_context.cpp:
##########
@@ -209,13 +209,32 @@ bool PipelineFragmentContext::notify_close() {
 // Method like exchange sink buffer will call query ctx cancel. If we add lock 
here
 // There maybe dead lock.
 void PipelineFragmentContext::cancel(const Status reason) {
+    if (notify_close()) {
+        return;
+    }
+    auto expected = LifecycleState::CREATED;
+    if (!_lifecycle_state.compare_exchange_strong(expected, 
LifecycleState::CANCELLING,

Review Comment:
   **Serialize cancellation publication with close**
   
   The lifecycle election can still lose a cancellation that began before 
close. A load's periodic-report callback invokes this `cancel()` directly on 
the report-pool thread, while a scheduler worker can finalize the last task 
independently. After `notify_close()` sees that task open, the worker can win 
`CREATED -> CLOSING` before this CAS, so this path returns without ever 
publishing the error. If this CAS wins first, `_try_start_close()` can consume 
`CANCELLING` before `_query_ctx->cancel()` below runs; `send_report(true)` then 
snapshots `QueryContext::exec_status()` as OK and can enqueue a successful 
final load report. Acquire/release does not help because the error write is 
sequenced after this CAS. Please keep close from completing until the elected 
cancellation has published the query failure, ensure a last close that arrives 
during publication is retried, and add a deterministic test that overlaps 
cancellation with the last decrement; the current tests join all cancel threads 
 before closing.



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