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

   ### What problem does this PR solve?
   
   Issue Number: close #62738
   
   Related PR: #xxx
   
   Problem Summary:
   
   When `enable_memory_orphan_check=true` is set in be.conf, the Backend crashes
     with the following assertion when cache background threads are triggered 
under
     load:
   
     Check failed: limiter_mem_tracker()->label() != "Orphan"
   
     The affected threads are `cache_adjust_capacity_thread` and
     `cache_prune_stale_thread` created in `daemon.cpp`. These threads perform
     memory allocations without a `MemTrackerLimiter` attached, so they fall 
back
     to the Orphan tracker. The crash is non-deterministic — it does not happen 
on
     startup but fires when cache pressure activates these background threads
     (e.g. cache near capacity or stale blocks present).
     
     ##### Root Cause
   
     Both cache daemon threads are created without calling `SCOPED_ATTACH_TASK`.
     Any thread without an explicit `MemTrackerLimiter` inherits the Orphan 
tracker.
     When `enable_memory_orphan_check=true`, memory allocation on the Orphan 
tracker
     triggers the assertion and crashes the BE.
     
     ##### Fix
   
     Attach a dedicated `MemTrackerLimiter` to each cache daemon thread via
     `SCOPED_ATTACH_TASK` before the work loop begins, consistent with how other
     daemon threads in the codebase handle memory tracking.
   
     ##### Files Changed
   
     `be/src/common/daemon.cpp` — add `SCOPED_ATTACH_TASK` to
       `cache_adjust_capacity_thread` and `cache_prune_stale_thread`
   
     ##### Tests
   
     - Verified no crash with `enable_memory_orphan_check=true` and file cache
       enabled under TPC-DS query load
     - Both cache threads now have a valid memory tracking context
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [X] No need to test or manual test. Explain why:
           - [X] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [X] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [X] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


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