Vamsi-klu opened a new pull request, #64025: URL: https://github.com/apache/airflow/pull/64025
This fixes a scheduler race where a task recovered through the public API could still leave downstream tasks permanently marked with terminal states based on stale scheduler-session data. Why: - `PATCH /taskInstances/...` already marks the selected task instance successful and clears downstream failed or upstream_failed task instances. - The scheduler could keep using a stale finished-task view from its own SQLAlchemy session during dependency evaluation. - That stale view could still drive downstream writes such as `UPSTREAM_FAILED` or `SKIPPED` after the recovery had already been committed. Impact: - A recovered upstream task no longer causes deeper descendants to be permanently written into stale terminal states by the scheduler. - Scheduler dependency evaluation now refreshes finished task instances from the database before using them for dependency checks. - The API behavior is unchanged: the fix is in scheduler-side state evaluation and its regression coverage. Files changed: - `airflow-core/src/airflow/models/dagrun.py` - `airflow-core/src/airflow/ti_deps/dep_context.py` - `airflow-core/tests/unit/models/test_dagrun.py` - `airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_task_instances.py` - `airflow-core/tests/unit/ti_deps/deps/test_not_previously_skipped_dep.py` Validation: - `breeze run pytest airflow-core/tests/unit/models/test_dagrun.py -k 'refresh_finished_tis' -xvs` - `breeze run pytest airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_task_instances.py::TestPatchTaskInstance::test_patch_success_clears_failed_downstream_and_requeues_dagrun -xvs` - `breeze run pytest airflow-core/tests/unit/ti_deps/deps/test_not_previously_skipped_dep.py::test_cleared_skipmixin_parent_does_not_skip_with_stale_finished_tis -xvs` - `prek run --from-ref origin/main --stage pre-commit` related: #63697 --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — OpenAI Codex GPT-5 Generated-by: OpenAI Codex GPT-5 following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- 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]
