hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Íñigo Goiri (JIRA) <j...@apache.org>
Subject [jira] [Commented] (HDFS-13990) Synchronization Issue With HashResolver.java
Date Sun, 14 Oct 2018 00:47:02 GMT

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

Íñigo Goiri commented on HDFS-13990:
------------------------------------

I would have to do a proper test on the performance of this with many threads but I'm not
sure if it is a good idea to make the gets synchronized.
In the current code, the worst case is multiple threads create an equivalent hash resolver.
I would have to read the implementation of ConcurrentHashMap in detail but I think a full
lock is worse than what we have now.

> 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