HIVE-19876: Multiple fixes for Driver.isValidTxnListState (Jesus Camacho Rodriguez, reviewed by Eugene Koifman)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/b1004830 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/b1004830 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/b1004830 Branch: refs/heads/master-txnstats Commit: b1004830ec95a74112ce37308d251b0366030824 Parents: dd51259 Author: Jesus Camacho Rodriguez <jcama...@apache.org> Authored: Thu Jun 14 20:52:33 2018 -0700 Committer: Jesus Camacho Rodriguez <jcama...@apache.org> Committed: Sat Jun 16 16:46:48 2018 -0700 ---------------------------------------------------------------------- .../java/org/apache/hadoop/hive/ql/Context.java | 1 + .../java/org/apache/hadoop/hive/ql/Driver.java | 30 +++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/b1004830/ql/src/java/org/apache/hadoop/hive/ql/Context.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Context.java b/ql/src/java/org/apache/hadoop/hive/ql/Context.java index e4e3d48..bb41e98 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/Context.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/Context.java @@ -356,6 +356,7 @@ public class Context { this.executionIndex = ctx.executionIndex; this.viewsTokenRewriteStreams = new HashMap<>(); this.rewrittenStatementContexts = new HashSet<>(); + this.opContext = new CompilationOpContext(); } public Map<String, Path> getFsScratchDirs() { http://git-wip-us.apache.org/repos/asf/hive/blob/b1004830/ql/src/java/org/apache/hadoop/hive/ql/Driver.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java index abeb7fc..43a78ca 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java @@ -815,33 +815,35 @@ public class Driver implements IDriver { // The lock may have multiple components, e.g., DbHiveLock, hence we need // to check for each of them for (LockComponent lckCmp : lock.getHiveLockComponents()) { - if (lckCmp.getType() == LockType.EXCLUSIVE || - lckCmp.getType() == LockType.SHARED_WRITE) { + // We only consider tables for which we hold either an exclusive + // or a shared write lock + if ((lckCmp.getType() == LockType.EXCLUSIVE || + lckCmp.getType() == LockType.SHARED_WRITE) && + lckCmp.getTablename() != null) { nonSharedLocks.add( Warehouse.getQualifiedName( lckCmp.getDbname(), lckCmp.getTablename())); } } } else { - // The lock has a single components, e.g., SimpleHiveLock or ZooKeeperHiveLock - if (lock.getHiveLockMode() == HiveLockMode.EXCLUSIVE || - lock.getHiveLockMode() == HiveLockMode.SEMI_SHARED) { - if (lock.getHiveLockObject().getPaths().length == 2) { - // Pos 0 of lock paths array contains dbname, pos 1 contains tblname - nonSharedLocks.add( - Warehouse.getQualifiedName( - lock.getHiveLockObject().getPaths()[0], lock.getHiveLockObject().getPaths()[1])); - } + // The lock has a single components, e.g., SimpleHiveLock or ZooKeeperHiveLock. + // Pos 0 of lock paths array contains dbname, pos 1 contains tblname + if ((lock.getHiveLockMode() == HiveLockMode.EXCLUSIVE || + lock.getHiveLockMode() == HiveLockMode.SEMI_SHARED) && + lock.getHiveLockObject().getPaths().length == 2) { + nonSharedLocks.add( + Warehouse.getQualifiedName( + lock.getHiveLockObject().getPaths()[0], lock.getHiveLockObject().getPaths()[1])); } } } // 3) Get txn tables that are being written - ValidTxnWriteIdList txnWriteIdList = - new ValidTxnWriteIdList(conf.get(ValidTxnWriteIdList.VALID_TABLES_WRITEIDS_KEY)); - if (txnWriteIdList == null) { + String txnWriteIdListStr = conf.get(ValidTxnWriteIdList.VALID_TABLES_WRITEIDS_KEY); + if (txnWriteIdListStr == null || txnWriteIdListStr.length() == 0) { // Nothing to check return true; } + ValidTxnWriteIdList txnWriteIdList = new ValidTxnWriteIdList(txnWriteIdListStr); List<Pair<String, Table>> writtenTables = getWrittenTableList(plan); ValidTxnWriteIdList currentTxnWriteIds = queryTxnMgr.getValidWriteIds(