Skip to content

Commit 5416b0f

Browse files
committed
Just protect client.
1 parent 424e987 commit 5416b0f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveMetastoreCatalog.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,16 @@ private[hive] class HiveMetastoreCatalog(hive: HiveContext) extends Catalog with
173173

174174
def lookupRelation(
175175
tableIdentifier: Seq[String],
176-
alias: Option[String]): LogicalPlan = synchronized {
176+
alias: Option[String]): LogicalPlan = {
177177
val tableIdent = processTableIdentifier(tableIdentifier)
178178
val databaseName = tableIdent.lift(tableIdent.size - 2).getOrElse(
179179
hive.sessionState.getCurrentDatabase)
180180
val tblName = tableIdent.last
181-
val table = try client.getTable(databaseName, tblName) catch {
181+
val table = try {
182+
synchronized {
183+
client.getTable(databaseName, tblName)
184+
}
185+
} catch {
182186
case te: org.apache.hadoop.hive.ql.metadata.InvalidTableException =>
183187
throw new NoSuchTableException
184188
}
@@ -200,7 +204,9 @@ private[hive] class HiveMetastoreCatalog(hive: HiveContext) extends Catalog with
200204
} else {
201205
val partitions: Seq[Partition] =
202206
if (table.isPartitioned) {
203-
HiveShim.getAllPartitionsOf(client, table).toSeq
207+
synchronized {
208+
HiveShim.getAllPartitionsOf(client, table).toSeq
209+
}
204210
} else {
205211
Nil
206212
}

0 commit comments

Comments
 (0)