首页 > 解决方案 > 错误:失败:获取锁时出错:与元存储 org.apache.hadoop.hive.ql.lockmgr.LockException 通信时出错

问题描述

Error in acquiring locks尝试在分区表上运行count(*)时获取,。当过滤 <= 350 个分区时,该表有 365个分区,查询工作正常。当尝试为查询包含更多分区时,它会因错误而失败。

处理 Hive 管理的 ACID 表,具有以下默认值

尝试通过直线会话增加/减少这些后续的值。

使用 HDI-4.0 交互式查询 llap 集群,元存储由提供的默认 sql-server 支持。

标签: hivehiveqlazure-hdinsightbeeline

解决方案


问题不是由于 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


推荐阅读