Alexander Kolbasov created HIVE-19241: -----------------------------------------
Summary: 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 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)