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

   ### Background
   
   Parallel scanner contexts of the same scan operator share a memory limiter. 
A query-level arbitrator sums scan operator estimates and uses their relative 
sizes to assign scan memory limits.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: None
   PR Type: Bugfix
   
   Problem Summary:
   
   A late scanner context can reset the contribution stored by its operator 
after an earlier context reports a new estimate. This overwrites the baseline 
without updating the query total, so the next refresh applies the wrong delta. 
The shared limiter now keeps registration, contribution changes, and final 
cleanup consistent under its existing mutex.
   
   ### Details
   
   - **Frequency:** Intermittent when scanner context initialization overlaps 
with adaptive scan scheduling.
   - **Root cause:** Context initialization writes the shared contribution 
independently of the query total, while scheduling reads and updates it without 
the limiter mutex.
   - **Why existing tests missed it:** The scanner memory tests exercised 
individual estimate and counter operations. They did not check the accounting 
across a late context open and the next refresh. Query-level scan regression 
tests validate scan results rather than this accounting.
   - **Fix:** Route registration, first open, refresh, and last close through 
the shared limiter. Later opens continue to contribute block samples. A context 
that fails before opening the limiter leaves the active count alone.
   - **Other paths and branches:** Both scanner schedulers use the shared 
limiter. The patch conflicts on branch-4.1 and branch-4.2, whose scan execution 
code lacks this memory arbitrator.
   
   ### Testing
   
   Clang-format 16, BE build hygiene, and git diff checks passed. Added unit 
coverage for a late open, last close, reopening, clamping, and destruction of a 
context that never opened the limiter. The BE unit tests and ThreadSanitizer 
have not been run on this patch.
   
   ### Release note
   
   Adaptive scan memory accounting stays correct when parallel scan instances 
initialize at different times.
   
   ### Check List (For Author)
   
   - Behavior changed: No
   - Does this need documentation: No
   - Pre-submission status: Partially verified: static checks passed and BE 
unit tests and ThreadSanitizer have not run.
   
   ### AI Disclosure
   
   - Tool: OpenAI Codex
   - Generated: Code, tests, and PR description
   - Human review: The author reviewed the patch and approved submission.
   


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