diff --git common/src/java/org/apache/hadoop/hive/conf/HiveConf.java common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index 102e6c6..a74815f 100644 --- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -2513,7 +2513,7 @@ private static void populateLlapDaemonVarsSet(Set llapDaemonVarsSetLocal "The port of ZooKeeper servers to talk to.\n" + "If the list of Zookeeper servers specified in hive.zookeeper.quorum\n" + "does not contain port numbers, this value is used."), - HIVE_ZOOKEEPER_SESSION_TIMEOUT("hive.zookeeper.session.timeout", "1200000ms", + HIVE_ZOOKEEPER_SESSION_TIMEOUT("hive.zookeeper.session.timeout", "120000ms", new TimeValidator(TimeUnit.MILLISECONDS), "ZooKeeper client's session timeout (in milliseconds). The client is disconnected, and as a result, all locks released, \n" + "if a heartbeat is not sent in the timeout."), @@ -2546,6 +2546,11 @@ private static void populateLlapDaemonVarsSet(Set llapDaemonVarsSetLocal "In nonstrict mode, for non-ACID resources, INSERT will only acquire shared lock, which\n" + "allows two concurrent writes to the same partition but still lets lock manager prevent\n" + "DROP TABLE etc. when the table is being written to"), + HIVE_TXN_STRICT_READ_LOCKS("hive.txn.strict.read.locks", false, "Read locks cannot protect\n" + + "non-ACID readers against concurrent inserts to the table. And the locks need to be explicitly\n" + + "unlocked partitition by partition, instead of being transactionally scoped.\n" + + "Allow these to be skipped in clusters where read locking is enabled globally to support ACID,\n." + + "but are being used for non-ACID tables unintentionally."), TXN_OVERWRITE_X_LOCK("hive.txn.xlock.iow", true, "Ensures commands with OVERWRITE (such as INSERT OVERWRITE) acquire Exclusive locks for\n" + "transactional tables. This ensures that inserts (w/o overwrite) running concurrently\n" + diff --git ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java index 71e5131..3e754f1 100644 --- ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java +++ ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java @@ -2238,6 +2238,7 @@ private static boolean isLockableTable(Table t) { public static List makeLockComponents(Set outputs, Set inputs, HiveConf conf) { List lockComponents = new ArrayList<>(); + final boolean strictReadLocks = conf.getBoolVar(ConfVars.HIVE_TXN_STRICT_READ_LOCKS); // For each source to read, get a shared lock for (ReadEntity input : inputs) { if (!input.needsLock() || input.isUpdateOrDelete() || !AcidUtils.needsLock(input)) { @@ -2273,11 +2274,17 @@ private static boolean isLockableTable(Table t) { // This is a file or something we don't hold locks for. continue; } + if (strictReadLocks == false && AcidUtils.isTransactionalTable(t) == false) { + // skip read-locks for non-transactional tables + // read-locks don't protect non-transactional tables data consistency + LOG.debug("Adding lock component to lock request on {} ", t); + continue; + } if (t != null) { compBuilder.setIsTransactional(AcidUtils.isTransactionalTable(t)); } LockComponent comp = compBuilder.build(); - LOG.debug("Adding lock component to lock request " + comp.toString()); + LOG.debug("Adding lock component to lock request {} ", comp); lockComponents.add(comp); } // For each source to write to, get the appropriate lock type. If it's