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


##########
be/src/runtime/query_context.cpp:
##########
@@ -343,7 +343,21 @@ void QueryContext::cancel(Status new_status, int 
fragment_id) {
     }
 
     set_ready_to_execute(new_status);
-    cancel_all_pipeline_context(new_status, fragment_id);
+
+    // Copy the fragment contexts under the map lock, then cancel them after 
releasing it. Fragment
+    // cancellation may take task-level locks and must not run while holding 
the query map lock.
+    std::vector<std::weak_ptr<PipelineFragmentContext>> ctx_to_cancel;
+    {

Review Comment:
   [P1] Reconcile cancellation with late fragment publication
   
   The query error is published before this snapshot, while 
`set_pipeline_context()` can insert afterward without observing the terminal 
status. A concrete recursive case is a cancel RPC arriving after the last 
task-prepare cancellation check but before FragmentMgr publishes a 
`need_notify_close` PFC: cancellation snapshots/removes the current query 
state, and the parent's one-shot `FINAL_CLOSE` can see `NotFound`; the prepare 
worker can then publish and submit the PFC. Its scheduler close path now 
re-enters `QueryContext::cancel()` and loses the first-error guard, so 
fragment-local `cancel()`/`notify_close()` never runs and 
`_close_fragment_instance()` cannot remove the PFC, leaving it and its 
QueryContext/rerunnable state strongly retained. Please linearize registration 
with cancellation (or reject publication into a terminal query), keep PFC 
cleanup outside the map lock, and cover this post-prepare race plus early 
`FINAL_CLOSE` deterministically.



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