hive - 错误:失败:获取锁时出错:与元存储 org.apache.hadoop.hive.ql.lockmgr.LockException 通信时出错
问题描述
Error in acquiring locks
尝试在分区表上运行count(*)时获取,。当过滤 <= 350 个分区时,该表有 365个分区,查询工作正常。当尝试为查询包含更多分区时,它会因错误而失败。
处理 Hive 管理的 ACID 表,具有以下默认值
- hive.support.concurrency=true //不能让它为假,它在抛出
<table> is missing from the ValidWriteIdList config: null
,对于 ACID 读写应该为真。 - hive.lock.manager=org.apache.hadoop.hive.ql.lockmgr.zookeeper.ZooKeeperHiveLockManager
- hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager
- hive.txn.strict.locking.mode=false
- hive.exec.dynamic.partition.mode=nonstrict
尝试通过直线会话增加/减少这些后续的值。
- hive.lock.numretries
- hive.unlock.numretries
- hive.lock.sleep.between.retries
- hive.metastore.batch.retrieve.max={default 300} //改为 10000
- hive.metastore.server.max.message.size={default 104857600} // 改为 10485760000
- hive.metastore.limit.partition.request={default -1} //没有改变,因为 -1 是无限的
- hive.metastore.batch.retrieve.max={default 300} //更改为 10000。
- hive.lock.query.string.max.length={default 10000} //更改为更高的值
使用 HDI-4.0 交互式查询 llap 集群,元存储由提供的默认 sql-server 支持。
解决方案
问题不是由于 hive 元存储数据库的服务层。这很可能是由于基于症状的一个查询中的分区太多。我多次遇到同样的问题。在 hivemetastore.log 中,您应该能够看到这样的错误:
metastore.RetryingHMSHandler: MetaException(message:Unable to update transaction database com.microsoft.sqlserver.jdbc.SQLServerException: The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:254)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1608)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:578)
这是因为在 Hive Metastore 中,hive 查询中涉及的每个分区最多需要 8 个参数来获取锁。
一些可能的解决方法:
将查询分解为多个子查询以从更少的分区中读取。
通过设置不同的分区键来减少分区的数量。
如果分区键没有任何过滤器,请删除分区。
以下是管理直接 SQL 生成的 INSERT 查询的批量大小的参数。它们的默认值为 1000。在 Hive configs via 的 Custom hive-site 部分中将它们都设置为 100(作为一个很好的起点)。Ambari 并重新启动所有 Hive 相关组件(包括 Hive 元存储)。
hive.direct.sql.max.elements.values.clause=100 hive.direct.sql.max.elements.in.clause=100
推荐阅读
- python - 散点图 matplotlib 的标记样式
- laravel - nuxtjs 如何/在哪里设置授权标头
- python - 使用映射数据框替换 pyspark 数据框几列中的值
- php - Laravel 验证存在于 company_id 中
- bash - 以编程方式为数组中的项目创建带有标志的 bash 命令
- rfc - 在BFCP中,席位控制服务器如何通知席位椅?
- python - How to round all floats in a text file using Python
- python-3.x - 如何修复权限被拒绝(cx-freeze)错误[python]?
- maven - 无法解析配置“:classpath”的所有工件。无法解析 com.android.tools.build:gradle:4.2.2
- azure - 持续更新 Azure 自动 ML 时间序列模型