Repository: spark
Updated Branches:
  refs/heads/master 17333c7a3 -> fcad3fae6


[SPARK-3746][SQL] Lock hive client when creating tables

Author: Michael Armbrust <[email protected]>

Closes #2598 from marmbrus/hiveClientLock and squashes the following commits:

ca89fe8 [Michael Armbrust] Lock hive client when creating tables


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/fcad3fae
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/fcad3fae
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/fcad3fae

Branch: refs/heads/master
Commit: fcad3fae6135bc2c9bdaf9e4c3cfe24838e63eae
Parents: 17333c7
Author: Michael Armbrust <[email protected]>
Authored: Wed Oct 1 14:37:27 2014 -0700
Committer: Michael Armbrust <[email protected]>
Committed: Wed Oct 1 14:37:27 2014 -0700

----------------------------------------------------------------------
 .../org/apache/spark/sql/hive/HiveMetastoreCatalog.scala  | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/fcad3fae/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala
----------------------------------------------------------------------
diff --git 
a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala 
b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala
index 9a0b9b4..06b1446 100644
--- 
a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala
+++ 
b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala
@@ -96,10 +96,12 @@ private[hive] class HiveMetastoreCatalog(hive: HiveContext) 
extends Catalog with
     serDeInfo.setParameters(Map[String, String]())
     sd.setSerdeInfo(serDeInfo)
 
-    try client.createTable(table) catch {
-      case e: org.apache.hadoop.hive.ql.metadata.HiveException
-        if 
e.getCause.isInstanceOf[org.apache.hadoop.hive.metastore.api.AlreadyExistsException]
 &&
-           allowExisting => // Do nothing.
+    synchronized {
+      try client.createTable(table) catch {
+        case e: org.apache.hadoop.hive.ql.metadata.HiveException
+          if 
e.getCause.isInstanceOf[org.apache.hadoop.hive.metastore.api.AlreadyExistsException]
 &&
+             allowExisting => // Do nothing.
+      }
     }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to