[ 
https://issues.apache.org/jira/browse/YARN-11843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18014564#comment-18014564
 ] 

ASF GitHub Bot commented on YARN-11843:
---------------------------------------

TaoYang526 commented on PR #7855:
URL: https://github.com/apache/hadoop/pull/7855#issuecomment-3196066838

   Updated the expected state in 
AbstractYarnScheduler#recoverResourceRequestForContainer and added UT for that.




> Fix potential deadlock when auto-correction of container allocation is enabled
> ------------------------------------------------------------------------------
>
>                 Key: YARN-11843
>                 URL: https://issues.apache.org/jira/browse/YARN-11843
>             Project: Hadoop YARN
>          Issue Type: Bug
>          Components: scheduler
>    Affects Versions: 3.5.0
>            Reporter: Tao Yang
>            Assignee: Tao Yang
>            Priority: Major
>              Labels: pull-request-available
>
> The feature introduced in YARN-11702 has a potential deadlock issue. When 
> enabled, it can cause deadlock when holding application-level write locks 
> while trying to acquire queue-level write locks.
>  
> Root Cause:
>  - autoCorrectContainerAllocation is called while holding application-level 
> write locks
>  - It directly calls completedContainer() which requires queue-level write 
> locks
> {code:java}
> CapacityScheduler#allocate
>    --> ...
>        application.getWriteLock().lock();   //1. requires app writeLock!!!
>        try{
>            ...
>            AbstractYarnScheduler#autoCorrectContainerAllocation
>               --> AbstractYarnScheduler#completedContainer 
>                   --> AbstractYarnScheduler#completedContainerInternal
>                       --> AbstractLeafQueue#completedContainer
>                            writeLock.lock()  //2. requires queue writeLock!!!
>                            try{
>                                ...
>                                FiCaSchedulerApp#containerCompleted
>                                    //3. requires app writeLock!!!
>                            }finally{
>                                writeLock.unlock();
>                            }
>        }finally{
>            application.getWriteLock().unlock();
>        }{code}
>  - This violates lock hierarchy and creates deadlock scenarios, since 
> AbstractYarnScheduler#completedContainer could be called from another thread 
> during normal container completion operations.
>  
> Solution:
> Replace direct completedContainer() calls with asyncContainerRelease() in 
> autoCorrectContainerAllocation method.
> Before:
> {code:java}
> completedContainer(rmContainer, ...); // Direct call causes deadlock {code}
> After:
> {code:java}
> asyncContainerRelease(rmContainer); // Async call avoids deadlock {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: yarn-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org

Reply via email to