[ 
https://issues.apache.org/jira/browse/IMPALA-12079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17715323#comment-17715323
 ] 

ASF subversion and git services commented on IMPALA-12079:
----------------------------------------------------------

Commit 4c5c49947083e0e47154583069963b69db7d62df in impala's branch 
refs/heads/master from stiga-huang
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=4c5c49947 ]

IMPALA-12079: Print more details for uncaught exceptions in impala-shell

In _do_beeswax_rpc(), the exception handling code tries to recognize the
exception and raise more meaningful exceptions. However, in the last
case for unknown exceptions, it does nothing so the method just returns
None. This makes the caller come into the error complaining 'NoneType'
object is not iterable, since the caller expects the result is a tuple
of two items:

 handle, rpc_status = self._do_beeswax_rpc(...)

This patch prints more details of the unknown exception and finally
raise an exception in _do_beeswax_rpc(). So the callers can show more
meaningful errors.

Tests:
I can't reproduce the error mentioned in the JIRA description. So I
manually modify the code to give _do_beeswax_rpc() a function that will
always throw an exception. Here is the console output:

$ impala-shell.sh --protocol=beeswax
[localhost:21000] default> select 1;
Query: select 1
Query submitted at: 2023-04-21 10:24:57 (Coordinator: 
http://quanlong-OptiPlex-BJ:25000)
Caught exception My error, type=<type 'exceptions.Exception'>
Traceback (most recent call last):
  File "/home/quanlong/workspace/Impala/shell/impala_client.py", line 1531, in 
_do_beeswax_rpc
    ret = rpc()
  File "/home/quanlong/workspace/Impala/shell/impala_client.py", line 1412, in 
myFunc
    raise Exception("My error")
Exception: My error
Unknown Exception : Encountered unknown exception
Traceback (most recent call last):
  File "/home/quanlong/workspace/Impala/shell/impala_shell.py", line 1325, in 
_execute_stmt
    query_str, self.set_query_options)
  File "/home/quanlong/workspace/Impala/shell/impala_client.py", line 1414, in 
execute_query
    handle, rpc_status = self._do_beeswax_rpc(myFunc)
  File "/home/quanlong/workspace/Impala/shell/impala_client.py", line 1604, in 
_do_beeswax_rpc
    raise Exception("Encountered unknown exception")
Exception: Encountered unknown exception
[Not connected] > Goodbye quanlong

Change-Id: I7d847251d3dab815af2427bf7701d60dc05af659
Reviewed-on: http://gerrit.cloudera.org:8080/19777
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>


> NoneType object is not iterable due to uncaught exceptions
> ----------------------------------------------------------
>
>                 Key: IMPALA-12079
>                 URL: https://issues.apache.org/jira/browse/IMPALA-12079
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Clients
>            Reporter: Quanlong Huang
>            Assignee: Quanlong Huang
>            Priority: Critical
>
> We saw impala-shell crashed with the following error:
> {code:python}
> Query: ALTER table xxx recover partitions
> Unknown Exception : 'NoneType' object is not iterable
> Traceback (most recent call last):
>   File 
> "/cs/cloudera/opt/cloudera/parcels/CDH-7.1.7-1.cdh7.1.7.p1055.31529794/bin/../lib/impala-shell/impala_shell.py",
>  line 1131, in _execute_stmt
>     query_str, self.set_query_options)
>   File 
> "/cs/cloudera/opt/cloudera/parcels/CDH-7.1.7-1.cdh7.1.7.p1055.31529794/lib/impala-shell/lib/impala_client.py",
>  line 1069, in execute_query
>     handle, rpc_status = self._do_beeswax_rpc(lambda: 
> self.imp_service.query(query))
> TypeError: 'NoneType' object is not iterable {code}
> After adding some logs in "_do_beeswax_rpc()", we found it's due to an 
> uncaught exception:
> {code:python}
> <class 'socket.error'> [Errno 104] Connection reset by peer{code}
> Here is a code sniper (after adding the debug log) of impala_client.py:
> {code:python}
>   def _do_beeswax_rpc(self, rpc, suppress_error_on_cancel=True):
>     ...
>     except Exception as e:
>       ...
>       print(type(e), str(e))  # Added this debug log
>       if suppress_error_on_cancel and self.is_query_cancelled:
>         raise QueryCancelledByShellException()
>       else:
>         if "BeeswaxException" in str(e):
>           raise RPCException("ERROR: %s" % e.message)
>         if "QueryNotFoundException" in str(e):
>           raise QueryStateException('Error: Stale query handle')
>       # The exception doesn't match any cases above so the method returns 
> None{code}
> Unfortunately, I can't reproduce this in house and we didn't get chance to 
> dig into where the exception come from. We should fix impala-shell anyway to 
> expose the exception instead of returning None and crashing itself.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to