You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by "BELUGA BEHR (JIRA)" <ji...@apache.org> on 2018/10/12 18:11:00 UTC

[jira] [Created] (HDFS-13990) Synchronization Issue With HashResolver.java

BELUGA BEHR created HDFS-13990:
----------------------------------

             Summary: 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
         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-dev-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-dev-help@hadoop.apache.org