aboutsummaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMichael Armbrust <michael@databricks.com>2014-07-15 00:13:51 -0700
committerAaron Davidson <aaron@databricks.com>2014-07-15 00:13:51 -0700
commitc7c7ac83392b10abb011e6aead1bf92e7c73695e (patch)
tree425b1b41b6ea693eecc9b54a0a4d2f2f26e5b8fe /sql
parentc6d75745de58ff1445912bf72a58b6ad2b3f863c (diff)
downloadspark-c7c7ac83392b10abb011e6aead1bf92e7c73695e.tar.gz
spark-c7c7ac83392b10abb011e6aead1bf92e7c73695e.tar.bz2
spark-c7c7ac83392b10abb011e6aead1bf92e7c73695e.zip
[SPARK-2485][SQL] Lock usage of hive client.
Author: Michael Armbrust <michael@databricks.com> Closes #1412 from marmbrus/lockHiveClient and squashes the following commits: 4bc9d5a [Michael Armbrust] protected[hive] 22e9177 [Michael Armbrust] Add comments. 7aa8554 [Michael Armbrust] Don't lock on hive's object. a6edc5f [Michael Armbrust] Lock usage of hive client.
Diffstat (limited to 'sql')
-rw-r--r--sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala5
1 files changed, 3 insertions, 2 deletions
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 f830688607..8db60d3276 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
@@ -43,14 +43,15 @@ import scala.collection.JavaConversions._
private[hive] class HiveMetastoreCatalog(hive: HiveContext) extends Catalog with Logging {
import HiveMetastoreTypes._
- val client = Hive.get(hive.hiveconf)
+ /** Connection to hive metastore. Usages should lock on `this`. */
+ protected[hive] val client = Hive.get(hive.hiveconf)
val caseSensitive: Boolean = false
def lookupRelation(
db: Option[String],
tableName: String,
- alias: Option[String]): LogicalPlan = {
+ alias: Option[String]): LogicalPlan = synchronized {
val (dbName, tblName) = processDatabaseAndTableName(db, tableName)
val databaseName = dbName.getOrElse(hive.sessionState.getCurrentDatabase)
val table = client.getTable(databaseName, tblName)