[ 
https://issues.apache.org/jira/browse/HADOOP-18236?focusedWorklogId=771961&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-771961
 ]

ASF GitHub Bot logged work on HADOOP-18236:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/May/22 15:23
            Start Date: 18/May/22 15:23
    Worklog Time Spent: 10m 
      Work Description: ZanderXu commented on PR #4320:
URL: https://github.com/apache/hadoop/pull/4320#issuecomment-1130159428

   Thanks @Hexiaoqiao for your comment, and I have read 
[HADOOP-16028](https://issues.apache.org/jira/browse/HADOOP-16028) in detail. 
If we look at this function without context, it is indeed necessary to add the 
read lock. But if with the context, the read lock in this function is indeed 
redundant, and instead will cause this logic to look a little confusing.




Issue Time Tracking
-------------------

    Worklog Id:     (was: 771961)
    Time Spent: 40m  (was: 0.5h)

> Remove duplicate locks in NetworkTopology
> -----------------------------------------
>
>                 Key: HADOOP-18236
>                 URL: https://issues.apache.org/jira/browse/HADOOP-18236
>             Project: Hadoop Common
>          Issue Type: Improvement
>            Reporter: ZanderXu
>            Assignee: ZanderXu
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> During reading the hadoop NetworkTopology.java, I suspect there is a 
> duplicate lock.
> chooseRandom(line 532), and code is:
> {code:java}
> final int availableNodes;
> if (excludedScope == null) {
>   availableNodes = countNumOfAvailableNodes(scope, excludedNodes);
> } else {
>   netlock.readLock().lock();
>   try {
>     availableNodes = countNumOfAvailableNodes(scope, excludedNodes) -
>         countNumOfAvailableNodes(excludedScope, excludedNodes);
>   } finally {
>     netlock.readLock().unlock();
>   }
> } {code}
> All the places where called `chooseRandom` have the global read lock, so the 
> internal read lock is duplicated.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to