hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xu...@apache.org
Subject svn commit: r1647855 - /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DummyTxnManager.java
Date Wed, 24 Dec 2014 22:39:47 GMT
Author: xuefu
Date: Wed Dec 24 22:39:47 2014
New Revision: 1647855

URL: http://svn.apache.org/r1647855
Log:
HIVE-9199: Excessive exclusive lock used in some DDLs with DummyTxnManager (Chaoyu via Xuefu,
reviewed by Alan)

Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DummyTxnManager.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DummyTxnManager.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DummyTxnManager.java?rev=1647855&r1=1647854&r2=1647855&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DummyTxnManager.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DummyTxnManager.java Wed Dec
24 22:39:47 2014
@@ -110,6 +110,9 @@ class DummyTxnManager extends HiveTxnMan
     // If a lock needs to be acquired on any partition, a read lock needs to be acquired
on all
     // its parents also
     for (ReadEntity input : plan.getInputs()) {
+      if (!input.needsLock()) {
+        continue;
+      }
       LOG.debug("Adding " + input.getName() + " to list of lock inputs");
       if (input.getType() == ReadEntity.Type.DATABASE) {
         lockObjects.addAll(getLockObjects(plan, input.getDatabase(), null,
@@ -125,18 +128,18 @@ class DummyTxnManager extends HiveTxnMan
     }
 
     for (WriteEntity output : plan.getOutputs()) {
+      HiveLockMode lockMode = getWriteEntityLockMode(output);
+      if (lockMode == null) {
+        continue;
+      }
       LOG.debug("Adding " + output.getName() + " to list of lock outputs");
       List<HiveLockObj> lockObj = null;
       if (output.getType() == WriteEntity.Type.DATABASE) {
-        lockObjects.addAll(getLockObjects(plan, output.getDatabase(), null,
-            null,
-            output.isComplete() ? HiveLockMode.EXCLUSIVE : HiveLockMode.SHARED));
+        lockObjects.addAll(getLockObjects(plan, output.getDatabase(), null, null, lockMode));
       } else if (output.getTyp() == WriteEntity.Type.TABLE) {
-        lockObj = getLockObjects(plan, null, output.getTable(), null,
-            output.isComplete() ? HiveLockMode.EXCLUSIVE : HiveLockMode.SHARED);
+        lockObj = getLockObjects(plan, null, output.getTable(), null,lockMode);
       } else if (output.getTyp() == WriteEntity.Type.PARTITION) {
-        lockObj = getLockObjects(plan, null, null, output.getPartition(),
-            HiveLockMode.EXCLUSIVE);
+        lockObj = getLockObjects(plan, null, null, output.getPartition(), lockMode);
       }
       // In case of dynamic queries, it is possible to have incomplete dummy partitions
       else if (output.getTyp() == WriteEntity.Type.DUMMYPARTITION) {
@@ -249,6 +252,22 @@ class DummyTxnManager extends HiveTxnMan
     }
   }
 
+  private HiveLockMode getWriteEntityLockMode (WriteEntity we) {
+    HiveLockMode lockMode = we.isComplete() ? HiveLockMode.EXCLUSIVE : HiveLockMode.SHARED;
+    //but the writeEntity is complete in DDL operations, and we need check its writeType
to
+    //to determine the lockMode
+    switch (we.getWriteType()) {
+      case DDL_EXCLUSIVE:
+        return HiveLockMode.EXCLUSIVE;
+      case DDL_SHARED:
+        return HiveLockMode.SHARED;
+      case DDL_NO_LOCK:
+        return null;
+      default: //other writeTypes related to DMLs
+        return lockMode;
+    }
+  }
+
   private List<HiveLockObj> getLockObjects(QueryPlan plan, Database db,
                                            Table t, Partition p,
                                            HiveLockMode mode)



Mime
View raw message