所有查询的 Hive 错误:找不到与操作句柄关联的日志

Hive error on all queries: Couldn't find log associated with operation handle

Hadoop 上的所有配置单元查询 运行 出现错误。

只需 运行 来自 table 的 select 语句并得到以下结果:

Fetching results ran into the following error(s):

Couldn't find log associated with operation handle: 
OperationHandle[opType=EXECUTE_STATEMENT,
getHandleIdentifier()=263df9c3-c076-454f-a025-23f5b919e957]

查询的伴随日志是:

Bad status for request TFetchResultsReq(fetchType=1, operationHandle=TOperationHandle(hasResultSet=False, modifiedRowCount=None, operationType=0, operationId=THandleIdentifier(secret='%\x1d\x0f\x11\xce\xf4B\xd6\xb8\xb5\x8ddv\xceKV', guid="\xbc5\xd9|\xfa\x13J'\x86\x8e4\xb3\x87\xa0\xf4\x05")), orientation=4, maxRows=-1): TFetchResultsResp(status=TStatus(errorCode=0, errorMessage="Couldn't find log associated with operation handle: OperationHandle [opType=EXECUTE_STATEMENT, getHandleIdentifier()=bc35d97c-fa13-4a27-868e-34b387a0f405]", sqlState=None, infoMessages=["*org.apache.hive.service.cli.HiveSQLException:Couldn't find log associated with operation handle: OperationHandle [opType=EXECUTE_STATEMENT, getHandleIdentifier()=bc35d97c-fa13-4a27-868e-34b387a0f405]:25:24", 'org.apache.hive.service.cli.operation.OperationManager:getOperationLogRowSet:OperationManager.java:257', 'org.apache.hive.service.cli.session.HiveSessionImpl:fetchResults:HiveSessionImpl.java:656', 'sun.reflect.GeneratedMethodAccessor29:invoke::-1', 'sun.reflect.DelegatingMethodAccessorImpl:invoke:DelegatingMethodAccessorImpl.java:43', 'java.lang.reflect.Method:invoke:Method.java:606', 'org.apache.hive.service.cli.session.HiveSessionProxy:invoke:HiveSessionProxy.java:79', 'org.apache.hive.service.cli.session.HiveSessionProxy:access[=11=]0:HiveSessionProxy.java:37', 'org.apache.hive.service.cli.session.HiveSessionProxy:run:HiveSessionProxy.java:64', 'java.security.AccessController:doPrivileged:AccessController.java:-2', 'javax.security.auth.Subject:doAs:Subject.java:415', 'org.apache.hadoop.security.UserGroupInformation:doAs:UserGroupInformation.java:1628', 'org.apache.hadoop.hive.shims.HadoopShimsSecure:doAs:HadoopShimsSecure.java:536', 'org.apache.hive.service.cli.session.HiveSessionProxy:invoke:HiveSessionProxy.java:60', 'com.sun.proxy.$Proxy28:fetchResults::-1', 'org.apache.hive.service.cli.CLIService:fetchResults:CLIService.java:427', 'org.apache.hive.service.cli.thrift.ThriftCLIService:FetchResults:ThriftCLIService.java:587', 'org.apache.hive.service.cli.thrift.TCLIService$Processor$FetchResults:getResult:TCLIService.java:1553', 'org.apache.hive.service.cli.thrift.TCLIService$Processor$FetchResults:getResult:TCLIService.java:1538', 'org.apache.thrift.ProcessFunction:process:ProcessFunction.java:39', 'org.apache.thrift.TBaseProcessor:process:TBaseProcessor.java:39', 'org.apache.hive.service.auth.TSetIpAddressProcessor:process:TSetIpAddressProcessor.java:56', 'org.apache.thrift.server.TThreadPoolServer$WorkerProcess:run:TThreadPoolServer.java:206', 'java.util.concurrent.ThreadPoolExecutor:runWorker:ThreadPoolExecutor.java:1145', 'java.util.concurrent.ThreadPoolExecutor$Worker:run:ThreadPoolExecutor.java:615', 'java.lang.Thread:run:Thread.java:744'], statusCode=3), results=None, hasMoreRows=None) Bad status for request TFetchResultsReq(fetchType=1, operationHandle=TOperationHandle(hasResultSet=False, modifiedRowCount=None, operationType=0, operationId=THandleIdentifier(secret='c\xdf\xfe\xb7\x8a\x10D\xea\xbaD\x93}B\xb5\xc3\xe7', guid='&=\xf9\xc3\xc0vEO\xa0%#\xf5\xb9\x19\xe9W')), orientation=0, maxRows=-1): TFetchResultsResp(status=TStatus(errorCode=0, errorMessage="Couldn't find log associated with operation handle: OperationHandle [opType=EXECUTE_STATEMENT, getHandleIdentifier()=263df9c3-c076-454f-a025-23f5b919e957]", sqlState=None, infoMessages=["*org.apache.hive.service.cli.HiveSQLException:Couldn't find log associated with operation handle: OperationHandle [opType=EXECUTE_STATEMENT, getHandleIdentifier()=263df9c3-c076-454f-a025-23f5b919e957]:25:24", 'org.apache.hive.service.cli.operation.OperationManager:getOperationLogRowSet:OperationManager.java:257', 'org.apache.hive.service.cli.session.HiveSessionImpl:fetchResults:HiveSessionImpl.java:656', 'sun.reflect.GeneratedMethodAccessor29:invoke::-1', 'sun.reflect.DelegatingMethodAccessorImpl:invoke:DelegatingMethodAccessorImpl.java:43', 'java.lang.reflect.Method:invoke:Method.java:606', 'org.apache.hive.service.cli.session.HiveSessionProxy:invoke:HiveSessionProxy.java:79', 'org.apache.hive.service.cli.session.HiveSessionProxy:access[=11=]0:HiveSessionProxy.java:37', 'org.apache.hive.service.cli.session.HiveSessionProxy:run:HiveSessionProxy.java:64', 'java.security.AccessController:doPrivileged:AccessController.java:-2', 'javax.security.auth.Subject:doAs:Subject.java:415', 'org.apache.hadoop.security.UserGroupInformation:doAs:UserGroupInformation.java:1628', 'org.apache.hadoop.hive.shims.HadoopShimsSecure:doAs:HadoopShimsSecure.java:536', 'org.apache.hive.service.cli.session.HiveSessionProxy:invoke:HiveSessionProxy.java:60', 'com.sun.proxy.$Proxy28:fetchResults::-1', 'org.apache.hive.service.cli.CLIService:fetchResults:CLIService.java:427', 'org.apache.hive.service.cli.thrift.ThriftCLIService:FetchResults:ThriftCLIService.java:587', 'org.apache.hive.service.cli.thrift.TCLIService$Processor$FetchResults:getResult:TCLIService.java:1553', 'org.apache.hive.service.cli.thrift.TCLIService$Processor$FetchResults:getResult:TCLIService.java:1538', 'org.apache.thrift.ProcessFunction:process:ProcessFunction.java:39', 'org.apache.thrift.TBaseProcessor:process:TBaseProcessor.java:39', 'org.apache.hive.service.auth.TSetIpAddressProcessor:process:TSetIpAddressProcessor.java:56', 'org.apache.thrift.server.TThreadPoolServer$WorkerProcess:run:TThreadPoolServer.java:206', 'java.util.concurrent.ThreadPoolExecutor:runWorker:ThreadPoolExecutor.java:1145', 'java.util.concurrent.ThreadPoolExecutor$Worker:run:ThreadPoolExecutor.java:615', 'java.lang.Thread:run:Thread.java:744'], statusCode=3), results=None, hasMoreRows=None) Bad status for request TFetchResultsReq(fetchType=1, operationHandle=TOperationHandle(hasResultSet=False, modifiedRowCount=None, operationType=0, operationId=THandleIdentifier(secret='c\xdf\xfe\xb7\x8a\x10D\xea\xbaD\x93}B\xb5\xc3\xe7', guid='&=\xf9\xc3\xc0vEO\xa0%#\xf5\xb9\x19\xe9W')), orientation=0, maxRows=-1): TFetchResultsResp(status=TStatus(errorCode=0, errorMessage="Couldn't find log associated with operation handle: OperationHandle [opType=EXECUTE_STATEMENT, getHandleIdentifier()=263df9c3-c076-454f-a025-23f5b919e957]", sqlState=None, infoMessages=["*org.apache.hive.service.cli.HiveSQLException:Couldn't find log associated with operation handle: OperationHandle [opType=EXECUTE_STATEMENT, getHandleIdentifier()=263df9c3-c076-454f-a025-23f5b919e957]:25:24", 'org.apache.hive.service.cli.operation.OperationManager:getOperationLogRowSet:OperationManager.java:257', 'org.apache.hive.service.cli.session.HiveSessionImpl:fetchResults:HiveSessionImpl.java:656', 'sun.reflect.GeneratedMethodAccessor29:invoke::-1', 'sun.reflect.DelegatingMethodAccessorImpl:invoke:DelegatingMethodAccessorImpl.java:43', 'java.lang.reflect.Method:invoke:Method.java:606', 'org.apache.hive.service.cli.session.HiveSessionProxy:invoke:HiveSessionProxy.java:79', 'org.apache.hive.service.cli.session.HiveSessionProxy:access[=11=]0:HiveSessionProxy.java:37', 'org.apache.hive.service.cli.session.HiveSessionProxy:run:HiveSessionProxy.java:64', 'java.security.AccessController:doPrivileged:AccessController.java:-2', 'javax.security.auth.Subject:doAs:Subject.java:415', 'org.apache.hadoop.security.UserGroupInformation:doAs:UserGroupInformation.java:1628', 'org.apache.hadoop.hive.shims.HadoopShimsSecure:doAs:HadoopShimsSecure.java:536', 'org.apache.hive.service.cli.session.HiveSessionProxy:invoke:HiveSessionProxy.java:60', 'com.sun.proxy.$Proxy28:fetchResults::-1', 'org.apache.hive.service.cli.CLIService:fetchResults:CLIService.java:427', 'org.apache.hive.service.cli.thrift.ThriftCLIService:FetchResults:ThriftCLIService.java:587', 'org.apache.hive.service.cli.thrift.TCLIService$Processor$FetchResults:getResult:TCLIService.java:1553', 'org.apache.hive.service.cli.thrift.TCLIService$Processor$FetchResults:getResult:TCLIService.java:1538', 'org.apache.thrift.ProcessFunction:process:ProcessFunction.java:39', 'org.apache.thrift.TBaseProcessor:process:TBaseProcessor.java:39', 'org.apache.hive.service.auth.TSetIpAddressProcessor:process:TSetIpAddressProcessor.java:56', 'org.apache.thrift.server.TThreadPoolServer$WorkerProcess:run:TThreadPoolServer.java:206', 'java.util.concurrent.ThreadPoolExecutor:runWorker:ThreadPoolExecutor.java:1145', 'java.util.concurrent.ThreadPoolExecutor$Worker:run:ThreadPoolExecutor.java:615', 'java.lang.Thread:run:Thread.java:744'], statusCode=3), results=None, hasMoreRows=None)

此错误可能发生在 i.e(“hive.server2.logging.operation.log.location”) 指向不存在的位置以写入日志。

查看来自OperationManager.java

的代码
OperationLog operationLog = getOperation(opHandle).getOperationLog();
if (operationLog == null) {
  throw new HiveSQLException("Couldn't find log associated with operation handle: " + opHandle);
}

如果您在使用 Hue 时在 Cloudera 发行版中看到此内容,请将以下内容添加到 hive 的 Hive 服务高级配置片段(安全阀)-site.xml 在 Cloudera Manager 中(或直接进入 hive-site.xml 对于其他发行版):

<property>
    <name>hive.server2.logging.operation.enabled</name>
    <value>true</value>
</property>

如果您使用的是 AWS EMR,则将以下内容添加到位于 /etc/hive/conf.dist/hive-site.xml 的 hive-site.xml 文件中:

<property>
    <name>hive.server2.logging.operation.enabled</name>
    <value>true</value>
</property>

然后登录master节点,重启hue和hive server

sudo stop hive-server2
sudo stop hue
sudo start hue
sudo start hive-server2

这为我修复了它(在发布标签 emr-4.6.0 中测试)。

在 Windows 8.1 中,我在 hive 查询部分 -

中也面临相同的问题部分
org.apache.hive.service.cli.HiveSQLException: Couldn't find log associated with operation handle: OperationHandle [opType=EXECUTE_STATEMENT, getHandleIdentifier()=230485c4-a1be-4a17-94c8-a1ebce426319]

因此,我去了 %HIVE_HOME%/conf/hive-site.xml 并更改了 属性 名称 hive.server2.logging.operation.log.location 之前的值 ${system:user.name}/operation_logs 如下所示 -

  <property>
    <name>hive.server2.logging.operation.log.location</name>
    <value>/tmp/${user.name}/operation_logs</value>
    <description>Top level directory where operation logs are stored if logging functionality is enabled</description>
  </property>

并将所有包含 ${system:user.name} 的值替换为 /tmp/${user.name},这让我想到了配置单元中的作业日志记录问题,谢谢。

如果您 运行 由于 shell 脚本或 java 程序而陷入此问题,您首先需要检查的是连接字符串,我遇到过类似的问题几个月前发布,当时在我的脚本中 运行 以这种方式查询:

beeline -u  jdbc:hive2:// -e "show databases;"

这是由于缺少正确的 Hive 连接字符串,一旦我更正了连接字符串和 运行 查询,它 运行 没有任何问题:

beeline -u  jdbc:hive2://server.enterprise.org:10000/default -e "show databases;"

此答案仅针对使用脚本或代码的开发人员,对于 Hue/Cloudera 发行版,请参考上述答案。

干杯!

在 Azure 中您可以使用

    beeline -u 'jdbc:hive2://headnodehost:10001/;transportMode=http'

创建 table 时使用以下代码 -

Create external table if not exists TEST1 
(
col1 string,
col2 int,
col3 date
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' 
WITH SERDEPROPERTIES ('field.delim'=',') 
location 'hdfs:/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
tblproperties ("skip.header.line.count"="1")
;

选择是否使用 Hive 0.14 之前的旧 GetLog() thrift 调用来检索日志。 如果为 false,则改用 Hive 1.0 或更高版本的 FetchResults() thrift 调用

use_get_log_api=false

真为假