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

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

Commit 0292e296c0ebcb191fb988f2582856023dd1bb70 in impala's branch 
refs/heads/master from Riza Suminto
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=0292e296c ]

IMPALA-14426: Deflake TestImpalaShell.test_cancellation

TestImpalaShell.test_cancellation start failing when run with Python 3.9
with following error message

RuntimeError: reentrant call inside <_io.BufferedWriter name='<stderr>'>

This patch is a quick fix the by changing the stderr write from using
print() to os.write(). Note that the thread-safetyness isssue within
_signal_handler in impala_shell.py during query cancellation still
remains.

Testing:
Run and pass test_cancellation in RHEL9 with Python 3.9.

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


> TestImpalaShell.test_cancellation failed with Python3.9
> -------------------------------------------------------
>
>                 Key: IMPALA-14426
>                 URL: https://issues.apache.org/jira/browse/IMPALA-14426
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Clients
>    Affects Versions: Impala 5.0.0
>            Reporter: Riza Suminto
>            Assignee: Riza Suminto
>            Priority: Major
>             Fix For: Impala 5.0.0
>
>
> TestImpalaShell.test_cancellation failed in downstream build with Python3.9.
> {noformat}
> Stacktrace
> /data/jenkins/workspace/impala-cdw-master-core/repos/Impala/tests/shell/test_shell_commandline.py:563:
>  in test_cancellation
>     assert "Cancelling Query" in result.stderr, result.stderr
> E   AssertionError: 2025-09-10 10:54:04 [Exception] Unknown Exception 
> reentrant call inside <_io.BufferedWriter name='<stderr>'>
> E     Traceback (most recent call last):
> E       File 
> "/data/jenkins/workspace/impala-cdw-master-core/repos/Impala/shell/build/impala-shell-5.0.0-SNAPSHOT/install_py3.9/impala_shell/impala_shell.py",
>  line 739, in _signal_handler
> E         print(ImpalaShell.CANCELLATION_MESSAGE, file=sys.stderr)
> E     RuntimeError: reentrant call inside <_io.BufferedWriter name='<stderr>'>
> E     
> E     During handling of the above exception, another exception occurred:
> E     
> E     Traceback (most recent call last):
> E       File 
> "/data/jenkins/workspace/impala-cdw-master-core/repos/Impala/shell/build/impala-shell-5.0.0-SNAPSHOT/install_py3.9/impala_shell/impala_shell.py",
>  line 1482, in _execute_stmt
> E         self._print_if_verbose(
> E       File 
> "/data/jenkins/workspace/impala-cdw-master-core/repos/Impala/shell/build/impala-shell-5.0.0-SNAPSHOT/install_py3.9/impala_shell/impala_shell.py",
>  line 1218, in _print_if_verbose
> E         print(message, file=file_descriptor)
> E       File 
> "/data/jenkins/workspace/impala-cdw-master-core/repos/Impala/shell/build/impala-shell-5.0.0-SNAPSHOT/install_py3.9/impala_shell/impala_shell.py",
>  line 756, in _signal_handler
> E         print(err_details % (cancel_try + 1, 
> ImpalaShell.CANCELLATION_TRIES, err_msg),
> E     RuntimeError: reentrant call inside <_io.BufferedWriter name='<stderr>'>
> E     Could not execute command: select sleep(10) from 
> functional_parquet.alltypesagg
> E     
> E   assert 'Cancelling Query' in "2025-09-10 10:54:04 [Exception] Unknown 
> Exception reentrant call inside <_io.BufferedWriter 
> name='<stderr>'>\nTraceba..._io.BufferedWriter name='<stderr>'>\nCould not 
> execute command: select sleep(10) from functional_parquet.alltypesagg\n"
> E    +  where "2025-09-10 10:54:04 [Exception] Unknown Exception reentrant 
> call inside <_io.BufferedWriter 
> name='<stderr>'>\nTraceba..._io.BufferedWriter name='<stderr>'>\nCould not 
> execute command: select sleep(10) from functional_parquet.alltypesagg\n" = 
> <tests.shell.util.ImpalaShellResult object at 0x7fb1942fe5d0>.stderr{noformat}
> Changing the stderr printing from print() to os.write() seems to work because 
> os.write() directly calls the native API (a thin wrapper around the system 
> call), bypassing the Python IO stack (see the complete discussion 
> [here|https://stackoverflow.com/questions/75367828/runtimeerror-reentrant-call-inside-io-bufferedwriter-name-stdout]).



--
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