Doris-Breakwater commented on issue #70842:
URL: https://github.com/apache/doris/issues/70842#issuecomment-7077146671

   **Confirmed from source on `master` (`7eef244a412e`) and `branch-4.1` 
(`cdc717ccb19f`).** `QueryContext::cancel()` records the first error before 
taking its fragment snapshot. Both initial submission and recursive CTE 
`REBUILD` register the prepared fragment in the query map later, and 
`set_pipeline_context()` only inserts or replaces the entry. If cancellation 
snapshots the map first, the scheduler still sees the query error and closes 
any submitted tasks. Its call back to `QueryContext::cancel()` returns at the 
first-error guard, so that path never reaches fragment-local cancellation. This 
matches the task-close behavior change in #67344 and #67548. [Query 
cancellation](https://github.com/apache/doris/blob/7eef244a412e711ad3d54fe844c9217e7b14b0eb/be/src/runtime/query_context.cpp#L316-L375)
 · [4.1 
registration](https://github.com/apache/doris/blob/cdc717ccb19f5dcaa0c0dbe66b0b41bf2cc3e773/be/src/runtime/query_context.cpp#L420-L426)
 · [Scheduler](https://github.com/apache/doris/b
 
lob/7eef244a412e711ad3d54fe844c9217e7b14b0eb/be/src/exec/pipeline/task_scheduler.cpp#L73-L150)
   
   The retention case is a fragment with `need_notify_close` still set. Its 
last task can finish while the fragment manager keeps the fragment and, through 
it, the `QueryContext` alive. A recursive CTE `WAIT_FOR_DESTROY` or 
`FINAL_CLOSE` can also call `notify_close()`, so whether a given run leaves the 
fragment behind depends on whether that notification reaches the affected 
context. [Fragment 
close](https://github.com/apache/doris/blob/7eef244a412e711ad3d54fe844c9217e7b14b0eb/be/src/exec/pipeline/pipeline_fragment_context.cpp#L2264-L2337)
 · [Recursive CTE close and 
rebuild](https://github.com/apache/doris/blob/7eef244a412e711ad3d54fe844c9217e7b14b0eb/be/src/runtime/fragment_mgr.cpp#L1292-L1393)
   
   Please open the patch PR. Checking the stored error after publishing the 
fragment covers the missed-snapshot ordering. Run fragment cancellation after 
releasing `_pipeline_map_write_lock`, and ensure the registration and snapshot 
paths cannot repeat fragment-local cancellation when they overlap. Cover both 
registration paths in a deterministic regression test. Include a recursive CTE 
`REBUILD` whose `SUBMIT` never arrives, since `notify_close()` alone leaves 
prepared tasks awaiting closure. For initial registration, check that saved 
rerunnable parameters release their query reference even if registration races 
query teardown. [Notification and 
cancellation](https://github.com/apache/doris/blob/7eef244a412e711ad3d54fe844c9217e7b14b0eb/be/src/exec/pipeline/pipeline_fragment_context.cpp#L184-L267)
 · [Query 
teardown](https://github.com/apache/doris/blob/7eef244a412e711ad3d54fe844c9217e7b14b0eb/be/src/runtime/fragment_mgr.cpp#L442-L470)
   
   **Runtime evidence still needed.** Please include the exact BE build or 
commit, a minimal SQL and debug-point sequence, and a BE trace keyed by query 
ID, fragment ID, and recursion round. Record cancellation, registration, task 
close, and the `SUBMIT` and `FINAL_CLOSE` outcomes. A fragment-manager dump 
after cancellation showing the fragment still present with `_closed_tasks == 
_total_tasks` and `need_notify_close=true` would verify the reported retention. 
The regression test should assert that the fragment entry disappears and the 
query context is released.
   
   Breakwater-GitHub-Analysis-Slot: slot_6ca81f6fa94c
   


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