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

   ### Background
   
   Doris counts the pipeline tasks selected for a spill batch and normally 
resumes the query after all of them finish revoking memory. A blocking 
scheduler executes spill work, while a batch callback releases the query's 
memory dependency.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #61212 (introduced multi-level spill task accounting)
   PR Type: Bugfix
   
   Problem Summary:
   
   Spill submission failures, work skipped or discarded before execution, and 
termination exceptions can leave selected tasks unaccounted for. Termination 
can also replace an earlier revoke error. Tie each completion obligation to 
task ownership, settle unsubmitted tasks, and keep failed submission batches on 
the existing cancellation path instead of resuming normal execution. Most added 
lines are deterministic failure-path tests.
   
   ### Details
   
   - **Change map:** Production: +135/-31 across four files; tests: +615/-0 in 
one file (82% of additions); no generated files or documentation changes. 
Completion ownership and cleanup in `SpillContext`, `PipelineTask` and 
`RevokableTask` account for +105/-27; batch dispatch and callback handling in 
`QueryTaskController` account for +30/-4.
   - **Frequency:** Always under the exercised rejection, skip/drop and 
termination-failure conditions; production frequency is unmeasured.
   - **Root cause:** Completion depended on execution cleanup that could be 
bypassed or throw before decrementing. Batch submission abandoned the 
unsubmitted suffix on failure, and a cleanup exception could replace a returned 
revoke error.
   - **Why existing tests missed it:** `PipelineTaskTest.TEST_DO_REVOKE_MEMORY` 
and `TEST_REVOKE_MEMORY` use accepting schedulers and successful termination; 
the expired-fragment case omits the spill context. SQL suites such as 
`query_p0/sort_spill` check normal results without injecting scheduler 
rejection or asserting batch completion counts.
   - **Fix:** Transfer one obligation to each wrapper and then to an 
independent execution guard; unexecuted wrappers settle it on destruction. The 
dispatcher settles only the unsubmitted suffix. Publish submission failure 
before releasing the rejected wrapper, suppress normal batch resume on that 
failure, and retain the original error. The callback captures only a weak query 
reference.
   - **Other paths and branches:** Operators and sinks share this BE 
pipeline-task boundary. This change targets master; release branches were not 
validated and no backport applicability is claimed. FE, configuration defaults, 
protocols and spill formats are unchanged.
   - **Behavior change:** Secondary termination errors no longer replace the 
original revoke error; skipped, dropped and unsubmitted tasks settle their 
completion counts.
   
   ### Testing
   
   - Locally, `BUILD_TYPE_UT=ASAN ./run-be-ut.sh --run 
--filter='SpillCompletionFailureTest.*:PipelineTaskTest.*:QueryTaskControllerTest.*'
 -j 8`: 46/46 passed, including 22 new tests. On the unfixed baseline, the 
22-test suite had 16 assertion failures and exited 134 with a LeakSanitizer 
report; the final run passed without an ASAN/LSan report.
   - Locally, `./run-regression-test.sh --conf 
output/local-regression/regression-conf-14000.groovy --run -d 
query_p0/sort_spill -s sort_spill`: one suite passed, with no failures or 
skips. This checks normal forced-spill SQL results, not injected scheduler 
failures.
   
   ### Notes for Reviewers
   
   Guard destruction order is essential: submission failure must be visible 
before the final completion, and attachment/fragment lifetimes must cover 
execution completion. Missing completion counts do not by themselves prove a 
persistent SQL hang: cancellation and early unblocking already release the 
memory dependency.
   
   ### Release note
   
   Fix incomplete spill-task completion accounting on failure, cancellation and 
discarded work, and preserve the original revoke error when termination also 
fails.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: No
   - Pre-submission status: Ready
   
   ### AI Disclosure
   
   - Tool: Codex (model not stated)
   - Generated: Production code, tests and this description
   - Human review: not stated


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