Open alexjironkin opened 5 years ago
The default Dialect implements is_disconnect
to be always False
and individual dialects implement the specific version of this (see https://docs.sqlalchemy.org/en/13/core/internals.html?highlight=is_disconnect#sqlalchemy.engine.default.DefaultDialect.is_disconnect)
I think we need to do the following for Impyla in impala.sqlalchemy.ImpalaDialect
:
do_ping()
to use internal cursor.ping()
instead of using SELECT 1
is_disconnect()
to identify if this is a disconnect event. For example, is HiveServer2Error
always indicates a disconnect? Any others?We found more exceptions:
Traceback (most recent call last):
File "/opt/app-root/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "/opt/app-root/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 304, in execute
self._wait_to_finish() # make execute synchronous
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 380, in _wait_to_finish
raise OperationalError(resp.errorMessage)
impala.error.OperationalError: EndDataStream() to *.*.*.*:27000 failed: Network error: failed to read from TLS socket: Connection reset by peer (error 104)
File "/opt/app-root/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 517, in do_ping
cursor = dbapi_connection.cursor()
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 139, in cursor
cursor.execute('USE %s' % self.default_db)
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 302, in execute
configuration=configuration)
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 343, in execute_async
self._execute_async(op)
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 362, in _execute_async
operation_fn()
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 340, in op
async=True)
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 1027, in execute
return self._operation('ExecuteStatement', req)
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 957, in _operation
resp = self._rpc(kind, request)
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 923, in _rpc
response = self._execute(func_name, request)
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 937, in _execute
open_transport(transport)
File "/opt/app-root/lib/python3.6/site-packages/impala/hiveserver2.py", line 971, in open_transport
transport.open()
File "/opt/app-root/lib/python3.6/site-packages/thrift_sasl/__init__.py", line 61, in open
self._trans.open()
File "/opt/app-root/lib/python3.6/site-packages/thriftpy/transport/socket.py", line 96, in open
self.sock.connect(addr)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/ssl.py", line 1100, in connect
self._real_connect(addr, False)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/ssl.py", line 1091, in _real_connect
self.do_handshake()
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
AttributeError: 'NoneType' object has no attribute 'do_handshake'
Any progress on this?
Hi, sorry for long delay, yes lots of progress. With SQLAlchemy pool pre-ping we managed to eliminate these. The issue seems to stem from server drops connections and was unreliable (don't know if this was configuration issue or design we don't manage this service).
We did implement a SELECT 1
based ping, but as I mentioned there is your own ping method we should use. It would be great to see this implemented in impyla.
I met this problem and I solved it finally. The following url is my stackoverflow answer url:
impala.error.HiveServer2Error: Failed after retrying 3 times
We have intermittently been facing issues with:
Caused by:
We are using this in conjunction with sqlalchemy pools and started using pre_ping option:
However, this fails now and again. I have tracked the issue to:
caused by 3 failures in:
Unfortunately the default dialect from sqlalchemy in
do_ping()
method only catches:Any thoughts why this would not catch Broken pipes? Feels like
self.dbapi.Error
should be catching theimpala.error.HiveServer2Error
?Impala: 0.14.1 Python: 3.6