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

ASF GitHub Bot commented on HDFS-17813:
---------------------------------------

khazhen opened a new pull request, #7829:
URL: https://github.com/apache/hadoop/pull/7829

   ### Description of PR
   Refer to [HDFS-17813](https://issues.apache.org/jira/browse/HDFS-17813).
   
   The NameCache class is used to cache frequently used names in namenode, it 
promotes a name used more than useThreshold to the cache, the promote logic:
   
   ```
   K put(final K name) {
     K internal = cache.get(name);
     if (internal != null) {
       lookups++;
       return internal;
     }
   
     // Track the usage count only during initialization
     if (!initialized) {
       UseCount useCount = transientMap.get(name);
       if (useCount != null) {
         useCount.increment();
         if (useCount.get() >= useThreshold) {
           promote(name); // name got promoted
         }
         return useCount.value;
       }
       useCount = new UseCount(name);
       transientMap.put(name, useCount);
     }
     return null;
   } 
   
   ```
   When promoting, the cache stores the `name` parameter from put() instead of 
the existing useCount.value. This causes the returned value to change after a 
name is promoted, resulting in memory duplication.
   
   




> NameCache promote wrong name to cache map
> -----------------------------------------
>
>                 Key: HDFS-17813
>                 URL: https://issues.apache.org/jira/browse/HDFS-17813
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: namenode
>            Reporter: kazan
>            Priority: Minor
>
> The NameCache class is used to cache frequently used names in namenode, it 
> promotes a name used more than useThreshold to the cache, the promote logic:
> {code:java}
> K put(final K name) {
>   K internal = cache.get(name);
>   if (internal != null) {
>     lookups++;
>     return internal;
>   }
>   // Track the usage count only during initialization
>   if (!initialized) {
>     UseCount useCount = transientMap.get(name);
>     if (useCount != null) {
>       useCount.increment();
>       if (useCount.get() >= useThreshold) {
>         promote(name); // name got promoted
>       }
>       return useCount.value;
>     }
>     useCount = new UseCount(name);
>     transientMap.put(name, useCount);
>   }
>   return null;
> } {code}
> When promoting, the cache stores the `name` parameter from put() instead of 
> the existing useCount.value. This causes the returned value to change after a 
> name is promoted, resulting in memory duplication.



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

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

Reply via email to