Repository navigation
Move email notifications from scheduler to DAG processor - #55238
Merged
Merged
Conversation
kaxil
requested review from
XD-DENG,
ashb,
ephraimbuddy and
jedcunningham
as code owners
September 4, 2025 00:52
kaxil
force-pushed
the
move-sending-email
branch
2 times, most recently
from
September 4, 2025 01:56
d5bfe86 to
091756d
Compare
kaxil
force-pushed
the
move-sending-email
branch
from
September 4, 2025 02:08
091756d to
aa2725e
Compare
eladkal
approved these changes
Sep 4, 2025
eladkal
left a comment
Contributor
There was a problem hiding this comment.
I really wish I pushed more on removing the special email handling in favor of regular notifier as part of Airflow 3.
Member
Author
Me too :( |
kaxil
force-pushed
the
move-sending-email
branch
from
September 4, 2025 10:18
aa2725e to
8289b41
Compare
Email notifications for task failures and retries are now handled by the DAG processor instead of the scheduler, maintaining the architectural principle that the scheduler should never execute user code - even if it is just sending emails. Key changes: - Add `EmailCallbackRequest` for failure/retry notifications - Update scheduler to send email callback requests via executor to the DB - Remove email handling from TaskInstance.handle_failure method - Simplify fetch_handle_failure_context to remove template context usage This ensures the scheduler remains isolated from user code execution while preserving email notification functionality through the existing callback request pattern used for task and DAG callbacks. Part of apache#52141 closes apache#55211
kaxil
force-pushed
the
move-sending-email
branch
from
September 4, 2025 11:01
8289b41 to
d49ab67
Compare
1 of 2 tasks
1 of 2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Email notifications for task failures and retries are now handled by the DAG processor instead of the scheduler, maintaining the architectural principle that the scheduler should never execute user code - even if it is just sending emails.
Key changes:
EmailCallbackRequestfor failure/retry notificationsThis ensures the scheduler remains isolated from user code execution while preserving email notification functionality through the existing callback request pattern used for task and DAG callbacks.
Part of #51546
Closes #55211
You can run a task with sleep and kill the API-server to test it

Scheduler logs:
Dag Processor logs:
{"timestamp":"2025-09-04T01:29:37.476068","level":"info","event":"Filling up the DagBag from /files/dags/example_py.py","logger":"airflow.models.dagbag.DagBag"} {"timestamp":"2025-09-04T01:29:37.498998","level":"info","event":"Sending failure email for task simplest_dag","dag_id":"as","run_id":"manual__2025-09-04T01:29:22.437699+00:00","logger":"task"} {"timestamp":"2025-09-04T01:29:38.473826","level":"info","event":"Email alerting: attempt 1","logger":"airflow.utils.email"}^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.