Skip to content

Commit

Permalink
Remove custom signal handling in Triggerer (#23274)
Browse files Browse the repository at this point in the history
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
   * python/cpython#83803

Fixes: #19260
  • Loading branch information
potiuk authored Apr 27, 2022
1 parent 6cf0176 commit 6bdbed6
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions airflow/cli/commands/triggerer_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
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
Expand All @@ -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()

0 comments on commit 6bdbed6

Please sign in to comment.