原创问题定位分享(18)beeline连接spark thrift有时会卡住
Posted barneywill
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了原创问题定位分享(18)beeline连接spark thrift有时会卡住相关的知识,希望对你有一定的参考价值。
spark 2.1.1
beeline连接spark thrift之后,执行use database有时会卡住,而use database 在server端对应的是 setCurrentDatabase,
经过排查发现当时spark thrift正在执行insert操作,
org.apache.spark.sql.hive.execution.InsertIntoHiveTable
protected override def doExecute(): RDD[InternalRow] = { sqlContext.sparkContext.parallelize(sideEffectResult.asInstanceOf[Seq[InternalRow]], 1) } ... @transient private val externalCatalog = sqlContext.sharedState.externalCatalog protected[sql] lazy val sideEffectResult: Seq[InternalRow] = { ... externalCatalog.loadDynamicPartitions( externalCatalog.getPartitionOption( externalCatalog.loadPartition( externalCatalog.loadTable(
可见insert操作中可能会调用loadDynamicPartitions、getPartitionOption、loadPartition、loadTable等方法,
org.apache.spark.sql.hive.client.HiveClientImpl
def loadTable( loadPath: String, // TODO URI tableName: String, replace: Boolean, holdDDLTime: Boolean): Unit = withHiveState { ... def loadPartition( loadPath: String, dbName: String, tableName: String, partSpec: java.util.LinkedHashMap[String, String], replace: Boolean, holdDDLTime: Boolean, inheritTableSpecs: Boolean): Unit = withHiveState { ... override def setCurrentDatabase(databaseName: String): Unit = withHiveState {
而HiveClientImpl中对应的方法都会执行withHiveState,而withHiveState有synchronized,所以insert操作中的部分代码(比如loadPartition)和use database操作会被同步执行,当insert执行很慢时就会卡住所有的其他操作;
spark thrift中实现原理详见 https://www.cnblogs.com/barneywill/p/10137672.html
以上是关于原创问题定位分享(18)beeline连接spark thrift有时会卡住的主要内容,如果未能解决你的问题,请参考以下文章
原创大叔问题定位分享(29)datanode启动报错:50020端口被占用
原创大叔问题定位分享(34)Spring的RestTemplate请求json数据后内容被修改
原创大叔问题定位分享(33)oozie提交任务报错ArithmeticException: / by zero