hive-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Kolbasov (JIRA)" <j...@apache.org>
Subject [jira] [Assigned] (HIVE-19241) HMSHandler initialization isn't thread-safe
Date Tue, 15 May 2018 08:52:00 GMT

     [ https://issues.apache.org/jira/browse/HIVE-19241?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Alexander Kolbasov reassigned HIVE-19241:
-----------------------------------------

    Assignee: Marta Kuczora

> HMSHandler initialization isn't thread-safe
> -------------------------------------------
>
>                 Key: HIVE-19241
>                 URL: https://issues.apache.org/jira/browse/HIVE-19241
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 2.0.2, 3.0.0, 3.1.0
>            Reporter: Alexander Kolbasov
>            Assignee: Marta Kuczora
>            Priority: Major
>
> The code in HMSHandler uses the double-check anti-pattern:
> {code:java}
>     public HMSHandler(String name, Configuration conf, boolean init) throws MetaException
{
>       super(name);
>       this.conf = conf;
>       isInTest = MetastoreConf.getBoolVar(this.conf, ConfVars.HIVE_IN_TEST);
>       if (threadPool == null) { // No lock held!!
>         synchronized (HMSHandler.class) {
>           int numThreads = MetastoreConf.getIntVar(conf, ConfVars.FS_HANDLER_THREADS_COUNT);
>           threadPool = Executors.newFixedThreadPool(numThreads,
>               new ThreadFactoryBuilder().setDaemon(true)
>                   .setNameFormat("HMSHandler #%d").build());
>         }
>       }
> {code}
> Notice that the check for threadPool == null isn't protected.
> This means that users of threadPool may see thread pool that isn't completely initialized.
> See https://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html for a detailed
explanation.



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

Mime
View raw message