This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-3-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 9ee62df17a15ed37a500fa9eee10167d4c594d4b Author: Jarek Potiuk <[email protected]> AuthorDate: Wed Apr 27 18:18:19 2022 +0200 Remove custom signal handling in Triggerer (#23274) There is a bug in CPython (fixed in March 2022 but not yet released) that makes async.io handle SIGTERM improperly by using async unsafe functions and hanging the triggerer receive SIGPIPE while handling SIGTERN/SIGINT and deadlocking itself. Until the bug is handled we should rather rely on standard handling of the signals rather than adding our own signal handlers. Seems that even if our signal handler just run exit(0) - it caused a race condition that led to the hanging. More details: * https://bugs.python.org/issue39622 * https://github.com/python/cpython/issues/83803 Fixes: #19260 (cherry picked from commit 6bdbed6c43df3c5473b168a75c50e0139cc13e88) --- airflow/cli/commands/triggerer_command.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/airflow/cli/commands/triggerer_command.py b/airflow/cli/commands/triggerer_command.py index 82e7fde129..8bf4192680 100644 --- a/airflow/cli/commands/triggerer_command.py +++ b/airflow/cli/commands/triggerer_command.py @@ -24,7 +24,7 @@ from daemon.pidfile import TimeoutPIDLockFile from airflow import settings from airflow.jobs.triggerer_job import TriggererJob from airflow.utils import cli as cli_utils -from airflow.utils.cli import setup_locations, setup_logging, sigint_handler, sigquit_handler +from airflow.utils.cli import setup_locations, setup_logging, sigquit_handler @cli_utils.action_cli @@ -50,7 +50,19 @@ def triggerer(args): job.run() else: - signal.signal(signal.SIGINT, sigint_handler) - signal.signal(signal.SIGTERM, sigint_handler) + # There is a bug in CPython (fixed in March 2022 but not yet released) that + # makes async.io handle SIGTERM improperly by using async unsafe + # functions and hanging the triggerer receive SIGPIPE while handling + # SIGTERN/SIGINT and deadlocking itself. Until the bug is handled + # we should rather rely on standard handling of the signals rather than + # adding our own signal handlers. Seems that even if our signal handler + # just run exit(0) - it caused a race condition that led to the hanging. + # + # More details: + # * https://bugs.python.org/issue39622 + # * https://github.com/python/cpython/issues/83803 + # + # signal.signal(signal.SIGINT, sigint_handler) + # signal.signal(signal.SIGTERM, sigint_handler) signal.signal(signal.SIGQUIT, sigquit_handler) job.run()
