Skip to content

Stop task supervisors after an init process reaps its child#70163

Draft
hooiv wants to merge 1 commit into
apache:mainfrom
hooiv:codex/fix-70117-supervisor-reap
Draft

Stop task supervisors after an init process reaps its child#70163
hooiv wants to merge 1 commit into
apache:mainfrom
hooiv:codex/fix-70117-supervisor-reap

Conversation

@hooiv

@hooiv hooiv commented Jul 21, 2026

Copy link
Copy Markdown

What type of change is this?

Bug fix.

What does this PR do?

Fixes a task supervisor hang when an init process such as dumb-init reaps the task child before the supervisor collects its exit status.

psutil.Process.wait(timeout=0) raises NoSuchProcess in that situation. Previously, the supervisor left both _exit_code and _process_exit_monotonic unset, so the socket cleanup timeout never started and the supervisor could remain alive indefinitely while retaining task sockets and memory.

The supervisor now treats the child as exited with the same unknown exit code used by the existing already-terminated kill path and starts the cleanup timer. Added a regression test for the reaped-child path.

Fixes #70117.

Testing

  • uv run --project task-sdk ruff format task-sdk/src/airflow/sdk/execution_time/supervisor.py task-sdk/tests/task_sdk/execution_time/test_supervisor.py
  • uv run --project task-sdk ruff check --fix task-sdk/src/airflow/sdk/execution_time/supervisor.py task-sdk/tests/task_sdk/execution_time/test_supervisor.py
  • Focused Linux test: TestWatchedSubprocess::test_process_already_reaped — passed
  • Linux test_supervisor.py: 166 passed, 6 skipped; remaining failures/errors were pre-existing mounted-Windows checkout issues (path-sensitive log assertions, missing optional provider/shared-package setup)

Checklist

  • The change includes regression coverage.
  • The commit has a Signed-off-by line.
  • Full CI verification

Init processes such as dumb-init can reap a task child before the supervisor collects its exit status. Treat the process as exited so socket cleanup can enforce its deadline.

Signed-off-by: ADITYA CHAUHAN <125276621+hooiv@users.noreply.github.com>
@boring-cyborg

boring-cyborg Bot commented Jul 21, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task supervisor lingers indefinitely on CeleryExecutor with dumb-init (socket_cleanup_timeout never triggers)

1 participant