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

   ### Background
   
   Flight SQL fetches a result schema from the BE before the client reads its 
rows. The BE registers result buffers by query or fragment instance ID and 
releases unread data when a query is aborted.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #69945 (introduced the regression), #69996 (query cancellation 
across backends), #67644 (separate handling of missing buffers)
   PR Type: Bugfix
   
   Problem Summary:
   
   A failed Flight query could report "no arrow schema for this query" when 
cancellation removed its result buffer before schema retrieval. Preserve the 
original failure status until timed cleanup while still releasing unread rows 
immediately. Most of the patch tests failure ordering, reclamation and actual 
Flight error propagation.
   
   For example, this query now consistently reports the original percentile 
argument error in the Flight regression:
   
   ```sql
   SELECT percentile(number, -1) FROM numbers("number"="1000");
   ```
   
   The failure when cancellation preceded schema retrieval was reproduced 
before the fix with a deterministic native schema RPC test.
   
   ### Details
   
   - **Frequency:** Intermittent when cancellation completes before schema 
retrieval; the native test forces this ordering.
   - **Root cause:** `cancel_arrow_flight_buffers` removed the buffer 
registration and access to its failure status together. The later schema RPC 
failed in `find_buffer` before reading that status.
   - **Why existing tests missed it:** The Flight cancellation unit tests 
checked early-close cleanup, waiting readers and successful termination, but 
never fetched schema after failure cancellation. `test_aggregate_all_functions` 
checks percentile error text without controlling the ordering.
   - **Fix:** Save only the terminal status under the lock for the buffer map 
before removing each buffer. Return it for late lookups and reclaim it through 
the existing cancellation thread, including when sink failure skips normal 
cleanup during close. Protect schema status reads with the buffer mutex.
   - **Other paths and branches:** Cover query and instance IDs, sibling 
buffers, repeated cancellation and expiry without sink close. Existing 
LIMIT_REACH, FINISHED, normal EOF and early-close tests still pass. branch-4.1 
and branch-4.2 have the same pattern from #68630; branch-3.1 and branch-4.0 
lack this cancellation path. No RPC fields, defaults or session variables 
change.
   
   ### Testing
   
   - Native baseline: 21 tests passed; only the new cancellation-before-schema 
test failed, returning code 6 instead of 33 and losing the original message. 
With the fix, all 31 targeted tests passed in each of three repetitions (93 
executions).
   - A compiled mutant omitting status-expiry scheduling failed the new 
reclamation test; restoring the candidate passed again.
   - Real local FE + BE: `test_flight_query_error_after_cancel` passed with 80 
expected execution errors and 40 successful following queries across both 
result sink modes. `test_flight_cancel_cleanup` and 
`test_aggregate_all_functions` also passed through Flight.
   
   ### Notes for Reviewers
   
   Native and runtime tests used a compatible local build baseline with 
identical changed files. The task sources also passed compilation checks 
against regenerated protocol headers from current master. A complete build of 
current master was not run because the installed dependency package lacks 
MongoDB C Driver 2.0. Generic handling of missing buffers in #67644 is separate 
from preserving the original query status here.
   
   ### Release note
   
   Flight SQL returns the original execution error when a failed query is 
cancelled before its result schema is fetched.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Partially verified: native and runtime tests used a 
matching compatibility baseline; a complete build of current master was not run 
locally.
   
   ### AI Disclosure
   
   - Tool: Codex (GPT-6)
   - Generated: Implementation, tests, and description.
   - Human review: The author has not reviewed the generated code.
   


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