hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "BELUGA BEHR (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-13990) Synchronization Issue With HashResolver.java
Date Mon, 15 Oct 2018 14:14:00 GMT

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

BELUGA BEHR commented on HDFS-13990:
------------------------------------

The {{get(hash)}} code is synchronized internally, so in both scenarios (current code / my
patch), the code enters a synchronized block once.  My proposed patch has a 'null' check and
the call to {{get(hash)}} function inside it's synchronized block.  I don't think you'll see
any measurable difference in performance for those two operations.

If a new {{HashResolver}} is required, the current code must enter a synchronized section
two times.  

> Synchronization Issue With HashResolver.java
> --------------------------------------------
>
>                 Key: HDFS-13990
>                 URL: https://issues.apache.org/jira/browse/HDFS-13990
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: federation
>    Affects Versions: 3.2.0
>            Reporter: BELUGA BEHR
>            Assignee: BELUGA BEHR
>            Priority: Minor
>         Attachments: HDFS-13990.1.patch
>
>
> {code:java|title=HashResolver.java}
>   private ConsistentHashRing getHashResolver(final Set<String> namespaces) {
>     int hash = namespaces.hashCode();
>     ConsistentHashRing resolver = this.hashResolverMap.get(hash);
>     if (resolver == null) {
>       resolver = new ConsistentHashRing(namespaces);
>       this.hashResolverMap.put(hash, resolver);
>     }
>     return resolver;
>   }
> {code}
> The {{hashResolverMap}} is a {{ConcurrentHashMap}} so presumably there is concern here
for concurrency issues.  However, there is no synchronization around this method, so two threads
could call {{get(hash)}} both see a 'null' value and then both add two entries into the {{Map}}.
 Add synchronization here.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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


Mime
View raw message