我正在使用pyhive0.6.1在hive中运行一个长的ish insert查询,结果失败了 thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
大约5分钟后。在服务器端,查询将一直运行,直到成功完成。我对快速查询没有这个问题。
我不能用相同的python版本在mac上本地复制它:代码正确地等待,直到查询完成。发生这种情况的环境是基于python:3.6-slim. 除此之外,我正在安装libsasl2 dev和libsasl2 modules包,以及pyhive[hive]python包。
你知道为什么会这样吗?提前谢谢。
我使用的代码是:
import contextlib
from pyhive.hive import connect
def get_conn():
return connect(
host='my-host',
port=10000,
auth='NONE',
username='username',
database='database'
)
with contextlib.closing(get_conn()) as conn, \
contextlib.closing(conn.cursor()) as cur:
cur.execute('My long insert statement')
这是完整的回溯
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "/usr/local/lib/python3.6/site-packages/pyhive/hive.py", line 364, in execute
response = self._connection.client.ExecuteStatement(req)
File "/usr/local/lib/python3.6/site-packages/TCLIService/TCLIService.py", line 280, in ExecuteStatement
return self.recv_ExecuteStatement()
File "/usr/local/lib/python3.6/site-packages/TCLIService/TCLIService.py", line 292, in recv_ExecuteStatement
(fname, mtype, rseqid) = iprot.readMessageBegin()
File "/usr/local/lib/python3.6/site-packages/thrift/protocol/TBinaryProtocol.py", line 134, in readMessageBegin
sz = self.readI32()
File "/usr/local/lib/python3.6/site-packages/thrift/protocol/TBinaryProtocol.py", line 217, in readI32
buff = self.trans.readAll(4)
File "/usr/local/lib/python3.6/site-packages/thrift/transport/TTransport.py", line 60, in readAll
chunk = self.read(sz - have)
File "/usr/local/lib/python3.6/site-packages/thrift_sasl/__init__.py", line 166, in read
self._read_frame()
File "/usr/local/lib/python3.6/site-packages/thrift_sasl/__init__.py", line 170, in _read_frame
header = self._trans.readAll(4)
File "/usr/local/lib/python3.6/site-packages/thrift/transport/TTransport.py", line 60, in readAll
chunk = self.read(sz - have)
File "/usr/local/lib/python3.6/site-packages/thrift/transport/TSocket.py", line 132, in read
message='TSocket read 0 bytes')
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "/usr/local/lib/python3.6/contextlib.py", line 185, in __exit__
self.thing.close()
File "/usr/local/lib/python3.6/site-packages/pyhive/hive.py", line 221, in close
response = self._client.CloseSession(req)
File "/usr/local/lib/python3.6/site-packages/TCLIService/TCLIService.py", line 218, in CloseSession
return self.recv_CloseSession()
File "/usr/local/lib/python3.6/site-packages/TCLIService/TCLIService.py", line 230, in recv_CloseSession
(fname, mtype, rseqid) = iprot.readMessageBegin()
File "/usr/local/lib/python3.6/site-packages/thrift/protocol/TBinaryProtocol.py", line 134, in readMessageBegin
sz = self.readI32()
File "/usr/local/lib/python3.6/site-packages/thrift/protocol/TBinaryProtocol.py", line 217, in readI32
buff = self.trans.readAll(4)
File "/usr/local/lib/python3.6/site-packages/thrift/transport/TTransport.py", line 60, in readAll
chunk = self.read(sz - have)
File "/usr/local/lib/python3.6/site-packages/thrift_sasl/__init__.py", line 166, in read
self._read_frame()
File "/usr/local/lib/python3.6/site-packages/thrift_sasl/__init__.py", line 170, in _read_frame
header = self._trans.readAll(4)
File "/usr/local/lib/python3.6/site-packages/thrift/transport/TTransport.py", line 60, in readAll
chunk = self.read(sz - have)
File "/usr/local/lib/python3.6/site-packages/thrift/transport/TSocket.py", line 132, in read
message='TSocket read 0 bytes')
thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
1条答案
按热度按时间gopyfrb31#
引发的代码异常如下:
我想这可能是会议提出的
errno.ECONNRESET
服务器故意关闭连接时可能发生的错误(根据这个节点js econnreset,服务器可能会在太忙时终止连接,并发现连接已超过“keep alive”超时)您可以检查服务器的日志,并找出是否存在某种终止连接行为。
我不确定,只是提供了我的想法。