sortega opened a new pull request, #77691: URL: https://github.com/apache/airflow/pull/77691
`airflow standalone` starts the scheduler, dag-processor, triggerer and api-server as child processes, but `SubCommand.run` never waits on them. When a component exits (a crash, or the OS killing it under memory pressure), its output thread ends silently, the process is left `<defunct>`, and nothing restarts it. The api-server usually survives, so the UI keeps answering while `/api/v2/monitor/health` reports the scheduler or triggerer as unhealthy: deferred tasks never resume and scheduled tasks never start. The only recovery is restarting standalone. This PR makes `SubCommand` supervise its process: - After the process's output ends, it is reaped with `wait()`, so no zombie is left behind. - Unless `stop()` was called, the exit is reported in the existing combined output (e.g. `triggerer | Killed by SIGKILL, restarting in 2s`) and the component is started again. - Restarts back off exponentially, from 1s doubling to 60s, so a component that fails at startup doesn't spin. The backoff resets once a run lasts at least 60s. - `stop()` sets a flag under the same lock used for spawning, so shutdown never respawns a component, including one that is waiting out its backoff. No new output channels or options. Restarting is safe for the DB-heartbeating components: a new scheduler adopts orphaned task instances, and a new triggerer picks up unassigned triggers. Context: #72464 fixed component leaks when one fails to start, and listed changes to how standalone behaves as out of scope. This is one of those changes, kept to supervising the process. #60971 proposes an opt-in interactive mode using `mprocs`. This PR covers the default mode and doesn't conflict with that. Tests: unit tests for restarts with backoff, backoff reset after a stable run, no respawn after `stop()` (including during backoff), exit descriptions, and one test with a real child process that checks it is reaped and restarted. --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (please specify the tool below) Generated-by: Claude Code (Claude Opus 5.5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) --- * Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information. Note: commit author/co-author name and email in commits become permanently public when merged. * For fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed. * When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x). * For significant user-facing changes create newsfragment: `{pr_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments). You can add this file in a follow-up commit after the PR is created so you know the PR number. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
