The GitHub Actions job "Tests (AMD)" on airflow.git/fix_65505 has failed.
Run started by GitHub user cmettler (triggered by potiuk).

Head commit for run:
e3061c9050f53991dacb20ae87441d9bbe4be74e / Christoph 
<[email protected]>
Fix orphaned subprocesses and supervisor crash on heartbeat 409

When a running TaskInstance is forcibly transitioned out of `running`
(e.g. the scheduler resets a stale heartbeat, or an operator PATCHes the
state to `failed`), the task-runner's next heartbeat returns HTTP 409
and the supervisor kills the task. Before this change two things went
wrong on Linux:

1. Subprocesses the task-runner had spawned (`@task.virtualenv` /
   `PythonVirtualenvOperator` children, `DockerOperator` exec, Bash
   shells) were reparented to PID 1 and kept running as orphans until
   they finished on their own - wasting CPU, RAM and third-party API
   quota.
2. About 60s later, `_cleanup_open_sockets()` closed the selector while
   `_service_subprocess()` was still using it, so the supervisor
   crashed with `ValueError: I/O operation on closed epoll object`
   (regression from PR #51180).

The task-runner is now placed in its own session via `os.setsid()`
immediately after fork, so its process group ID equals its PID. The
supervisor's `kill()` signals the whole group via
`os.killpg(os.getpgid(pid), sig)`, which reaches every subprocess the
task-runner spawned. Grandchildren without a SIGTERM handler exit
promptly, close their inherited pipes, and the supervisor drains
`_open_sockets` normally - so `_cleanup_open_sockets()` is never
triggered and the selector is never closed mid-loop.

`os.killpg`/`os.getpgid` fall back to `self._process.send_signal(sig)`
on `ProcessLookupError` or `PermissionError`, preserving prior
behaviour when the group has vanished (e.g. the task was already
reaped) or permissions are lacking.

closes: #65505

Report URL: https://github.com/apache/airflow/actions/runs/26877165428

With regards,
GitHub Actions via GitBox


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

Reply via email to