You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Alexander Kolbasov (JIRA)" <ji...@apache.org> on 2018/05/15 08:53:00 UTC
[jira] [Commented] (HIVE-19241) HMSHandler initialization isn't
thread-safe
[ https://issues.apache.org/jira/browse/HIVE-19241?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16475507#comment-16475507 ]
Alexander Kolbasov commented on HIVE-19241:
-------------------------------------------
Marta - you re changing the code around it - may be you can fix this as well.
> 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)