Programmer-RD-AI opened a new pull request, #52729: URL: https://github.com/apache/airflow/pull/52729
This change addresses a race condition in the task runner where downstream failure callbacks might observe an uninitialized or stale `end_date` and `duration` on the `TaskInstance`. By explicitly setting `ti.end_date` before constructing the `TaskState` in all exception handlers, we guarantee that any `on_failure_callback` receives a fully populated context, preventing confusing debug sessions and user‐defined callback failures. **Key Changes:** * **Set `ti.end_date` early** in both `AirflowFailException` and generic exception handlers, before creating the `TaskState`. * **Populate `duration` automatically** by virtue of the populated `end_date`, ensuring callbacks can compute and report accurate runtime metrics. * **Update existing tests** and add a new test (`test_task_runner_on_failure_callback_context`) that verifies both `end_date` and non‐negative `duration` are present in the failure callback context. * **Fix race condition** where callbacks previously saw incomplete `TaskInstance` data, leading to misleading or missing timing information. This PR closes #52630 -- 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]
