Repository navigation
Fix one bad callback request crashing the Dag processor and dropping the rest - #70990
ephraimbuddy merged 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR prevents a single invalid callback request (e.g., due to the documented “Dag/task removed between scheduling and parsing” race) from crashing the Dag processor subprocess and causing the remainder of the callback batch to be dropped. It also ensures missing last_ti tasks surface as the intended race-condition ValueError rather than a raw TaskNotFound.
Changes:
- Wrap per-request callback execution so one failing request is logged and the rest of the batch continues.
- Route
last_titask lookup through_get_dag_with_taskto normalize missing-task behavior to the race-conditionValueError. - Add unit tests covering “continue after failed request” and “missing last_ti task raises ValueError”.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
airflow-core/src/airflow/dag_processing/processor.py |
Isolates callback request execution failures and normalizes missing-task lookup behavior via _get_dag_with_task. |
airflow-core/tests/unit/dag_processing/test_processor.py |
Adds regression tests for batch-continuation and missing last_ti task error behavior. |
794d893 to
0f78bfe
Compare
kaxil
left a comment
There was a problem hiding this comment.
Both points are addressed well. The ValueError fallback keeps the dag-level callback alive with minimal context and cites the produce_dag_callback precedent, and exclude={"context_from_server"} keeps run conf out of the payload on both the debug and the error path, with log_extra binding the identifying fields so the error line is filterable. Reverting the fix locally makes both new tests fail with the original signatures, so they cover the real paths rather than the wiring. One optional test hardening below, not a blocker.
…the rest A callback request that hits the documented race condition (the Dag or task was removed between scheduling the callback and parsing the file) raises out of _execute_callbacks, killing the parse subprocess. The remaining requests in the batch were already popped from the manager's queue, so on_failure_callback, on_retry_callback, and failure-email requests behind the bad one are lost permanently. Isolate each request so a failure is logged and the rest still execute, and route the last_ti task lookup through _get_dag_with_task so a removed task surfaces as the race-condition error instead of a raw TaskNotFound.
Avoids a second to_json() in the exception handler, where a serialization failure would mask the original error and abort the batch the handler exists to protect.
…hen only the task is gone The last_ti task lookup only enriches the callback context, so a task removed since the run should downgrade to the minimal context (as produce_dag_callback already does for an unrepresentable last_ti) instead of costing the user the callback. The failure log leaked user-supplied dag_run.conf at ERROR via the serialized request and carried no structured identifiers; it now excludes context_from_server and binds dag_id/run_id/ti_id so log filters can match the line.
…backs when only the task is gone
0f78bfe to
21d936d
Compare
Backport successfully created: v3-3-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
…nd dropping the rest (apache#70990) * Fix one bad callback request crashing the Dag processor and dropping the rest A callback request that hits the documented race condition (the Dag or task was removed between scheduling the callback and parsing the file) raises out of _execute_callbacks, killing the parse subprocess. The remaining requests in the batch were already popped from the manager's queue, so on_failure_callback, on_retry_callback, and failure-email requests behind the bad one are lost permanently. Isolate each request so a failure is logged and the rest still execute, and route the last_ti task lookup through _get_dag_with_task so a removed task surfaces as the race-condition error instead of a raw TaskNotFound. * Serialize callback request once per loop iteration Avoids a second to_json() in the exception handler, where a serialization failure would mask the original error and abort the batch the handler exists to protect. * Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone The last_ti task lookup only enriches the callback context, so a task removed since the run should downgrade to the minimal context (as produce_dag_callback already does for an unrepresentable last_ti) instead of costing the user the callback. The failure log leaked user-supplied dag_run.conf at ERROR via the serialized request and carried no structured identifiers; it now excludes context_from_server and binds dag_id/run_id/ti_id so log filters can match the line. * fixup! Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone (cherry picked from commit 13b2969) Co-authored-by: Ephraim Anierobi <[email protected]>
…nd dropping the rest (#70990) * Fix one bad callback request crashing the Dag processor and dropping the rest A callback request that hits the documented race condition (the Dag or task was removed between scheduling the callback and parsing the file) raises out of _execute_callbacks, killing the parse subprocess. The remaining requests in the batch were already popped from the manager's queue, so on_failure_callback, on_retry_callback, and failure-email requests behind the bad one are lost permanently. Isolate each request so a failure is logged and the rest still execute, and route the last_ti task lookup through _get_dag_with_task so a removed task surfaces as the race-condition error instead of a raw TaskNotFound. * Serialize callback request once per loop iteration Avoids a second to_json() in the exception handler, where a serialization failure would mask the original error and abort the batch the handler exists to protect. * Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone The last_ti task lookup only enriches the callback context, so a task removed since the run should downgrade to the minimal context (as produce_dag_callback already does for an unrepresentable last_ti) instead of costing the user the callback. The failure log leaked user-supplied dag_run.conf at ERROR via the serialized request and carried no structured identifiers; it now excludes context_from_server and binds dag_id/run_id/ti_id so log filters can match the line. * fixup! Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone (cherry picked from commit 13b2969) Co-authored-by: Ephraim Anierobi <[email protected]>
…nd dropping the rest (#70990) (#71608) * Fix one bad callback request crashing the Dag processor and dropping the rest A callback request that hits the documented race condition (the Dag or task was removed between scheduling the callback and parsing the file) raises out of _execute_callbacks, killing the parse subprocess. The remaining requests in the batch were already popped from the manager's queue, so on_failure_callback, on_retry_callback, and failure-email requests behind the bad one are lost permanently. Isolate each request so a failure is logged and the rest still execute, and route the last_ti task lookup through _get_dag_with_task so a removed task surfaces as the race-condition error instead of a raw TaskNotFound. * Serialize callback request once per loop iteration Avoids a second to_json() in the exception handler, where a serialization failure would mask the original error and abort the batch the handler exists to protect. * Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone The last_ti task lookup only enriches the callback context, so a task removed since the run should downgrade to the minimal context (as produce_dag_callback already does for an unrepresentable last_ti) instead of costing the user the callback. The failure log leaked user-supplied dag_run.conf at ERROR via the serialized request and carried no structured identifiers; it now excludes context_from_server and binds dag_id/run_id/ti_id so log filters can match the line. * fixup! Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone (cherry picked from commit 13b2969) Co-authored-by: Ephraim Anierobi <[email protected]>
…nd dropping the rest (#70990) (#71608) * Fix one bad callback request crashing the Dag processor and dropping the rest A callback request that hits the documented race condition (the Dag or task was removed between scheduling the callback and parsing the file) raises out of _execute_callbacks, killing the parse subprocess. The remaining requests in the batch were already popped from the manager's queue, so on_failure_callback, on_retry_callback, and failure-email requests behind the bad one are lost permanently. Isolate each request so a failure is logged and the rest still execute, and route the last_ti task lookup through _get_dag_with_task so a removed task surfaces as the race-condition error instead of a raw TaskNotFound. * Serialize callback request once per loop iteration Avoids a second to_json() in the exception handler, where a serialization failure would mask the original error and abort the batch the handler exists to protect. * Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone The last_ti task lookup only enriches the callback context, so a task removed since the run should downgrade to the minimal context (as produce_dag_callback already does for an unrepresentable last_ti) instead of costing the user the callback. The failure log leaked user-supplied dag_run.conf at ERROR via the serialized request and carried no structured identifiers; it now excludes context_from_server and binds dag_id/run_id/ti_id so log filters can match the line. * fixup! Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone (cherry picked from commit 13b2969) Co-authored-by: Ephraim Anierobi <[email protected]>
…nd dropping the rest (apache#70990) (apache#71608) * Fix one bad callback request crashing the Dag processor and dropping the rest A callback request that hits the documented race condition (the Dag or task was removed between scheduling the callback and parsing the file) raises out of _execute_callbacks, killing the parse subprocess. The remaining requests in the batch were already popped from the manager's queue, so on_failure_callback, on_retry_callback, and failure-email requests behind the bad one are lost permanently. Isolate each request so a failure is logged and the rest still execute, and route the last_ti task lookup through _get_dag_with_task so a removed task surfaces as the race-condition error instead of a raw TaskNotFound. * Serialize callback request once per loop iteration Avoids a second to_json() in the exception handler, where a serialization failure would mask the original error and abort the batch the handler exists to protect. * Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone The last_ti task lookup only enriches the callback context, so a task removed since the run should downgrade to the minimal context (as produce_dag_callback already does for an unrepresentable last_ti) instead of costing the user the callback. The failure log leaked user-supplied dag_run.conf at ERROR via the serialized request and carried no structured identifiers; it now excludes context_from_server and binds dag_id/run_id/ti_id so log filters can match the line. * fixup! Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone (cherry picked from commit 13b2969) Co-authored-by: Ephraim Anierobi <[email protected]> (cherry picked from commit b9154e5)
…nd dropping the rest (apache#70990) (apache#71608) * Fix one bad callback request crashing the Dag processor and dropping the rest A callback request that hits the documented race condition (the Dag or task was removed between scheduling the callback and parsing the file) raises out of _execute_callbacks, killing the parse subprocess. The remaining requests in the batch were already popped from the manager's queue, so on_failure_callback, on_retry_callback, and failure-email requests behind the bad one are lost permanently. Isolate each request so a failure is logged and the rest still execute, and route the last_ti task lookup through _get_dag_with_task so a removed task surfaces as the race-condition error instead of a raw TaskNotFound. * Serialize callback request once per loop iteration Avoids a second to_json() in the exception handler, where a serialization failure would mask the original error and abort the batch the handler exists to protect. * Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone The last_ti task lookup only enriches the callback context, so a task removed since the run should downgrade to the minimal context (as produce_dag_callback already does for an unrepresentable last_ti) instead of costing the user the callback. The failure log leaked user-supplied dag_run.conf at ERROR via the serialized request and carried no structured identifiers; it now excludes context_from_server and binds dag_id/run_id/ti_id so log filters can match the line. * fixup! Address review: keep run conf out of logs and deliver Dag callbacks when only the task is gone (cherry picked from commit 13b2969) Co-authored-by: Ephraim Anierobi <[email protected]> (cherry picked from commit b9154e5)
A callback request that hits the documented race condition (the Dag or task was removed between scheduling the callback and parsing the file) raises out of _execute_callbacks, killing the parse subprocess. The remaining requests in the batch were already popped from the manager's queue, so on_failure_callback, on_retry_callback, and failure-email requests behind the bad one are lost permanently. Isolate each request so a failure is logged and the rest still execute, and route the last_ti task lookup through _get_dag_with_task so a removed task surfaces as the race-condition error instead of a raw TaskNotFound.
Was generative AI tooling used to co-author this PR?
claude fable 5