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.
   
   


-- 
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: common-issues-unsubscr...@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to