vatsrahul1001 opened a new pull request, #77766: URL: https://github.com/apache/airflow/pull/77766
Uncooperative shutdowns leave unfinished jobs indefinitely. Hydrating every abandoned row makes health probes increasingly expensive. MySQL cannot semijoin an IN over a UNION ALL, so it ran the combined health query as a dependent subquery per job row and the cost still grew with job history. Two plain indexed queries stay flat. The alive rule now lives in one SQL helper next to Job._is_alive, so the health query and the jobs API filter cannot drift apart. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c4c7-1193-77df-941c-935af7861fbe (cherry picked from commit 8699a93e659038ae7726446a87d4857d75aa534f) Co-authored-by: Vlad Vladov <[email protected]> --- The automatic backport failed on a conflict in `airflow-core/src/airflow/jobs/job.py`, so this was cherry-picked manually (`-x`). Everything else applied cleanly. **Conflict resolution (one import line):** `from sqlalchemy import Index, Integer, String, and_, case, or_, select`. The `Uuid` import in `main` comes from #73561 (a Job associated with several teams), which is not on `v3-4-test`, and nothing here uses it. This fixes a 3.4.0 regression: `get_jobs_health` (added in 3.4.0) loaded every unfinished Job row, so API server CPU grew with abandoned Job history (#76745). **Verified locally:** jobs route, health monitor route, `test_airflow_health.py` and `test_base_job.py`: 87 passed (run against this branch's sources). Backport of #76751. Generated-by: Claude Code 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
