-
Notifications
You must be signed in to change notification settings - Fork 16.4k
fix schedule_downstream_tasks bug #42582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix schedule_downstream_tasks bug #42582
Conversation
|
Can you add test that prevent regression? |
Thank you for the suggestion. I've added test to prevent regression. Please check the latest commit. |
|
Also, DB tests currently fail |
shahar1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - I'm ok with merging it after resolving my last nitpick.
@potiuk / @uranusjr / @ephraimbuddy - any objections?
* fix schedule_downstream_tasks bug * remove partial_subset * Update comment --------- Co-authored-by: 维湘 <jiazhao.ljz@alibaba-inc.com> (cherry picked from commit 3fceaa6)
* fix schedule_downstream_tasks bug * remove partial_subset * Update comment --------- Co-authored-by: 维湘 <jiazhao.ljz@alibaba-inc.com>
* fix schedule_downstream_tasks bug * remove partial_subset * Update comment --------- Co-authored-by: 维湘 <jiazhao.ljz@alibaba-inc.com>
* fix schedule_downstream_tasks bug * remove partial_subset * Update comment --------- Co-authored-by: 维湘 <jiazhao.ljz@alibaba-inc.com>
Thanks for reporting! Could you please create a GitHub issue with a minimal example to reproduce it (considering the latest Airflow version)? |





closes: #42581
Problem Description
The trigger_rule of
task_one_successisone_success. When the upstream node oftask_one_successhas not yet run,task_one_successis skipped. According to the semantics ofone_success,task_one_successshould be able to run.In this scenario, Airflow turns on the
schedule_after_task_executionparameter, which means that after the upstream node finishes running, it will try to schedule the downstream node in the current worker.This problem may occur when
task_1runs faster thantask_run. More specifically, it occurs whentask_1finishes running and successfully schedules downstream tasks in the current worker.Related Code
Below is the code in question


When
task_1is finished, it will try to schedule downstream tasks. First, a partial dag will be generated.task => "task_1"task.downstream_task_ids => "task_2"include_downstream=True => ["task_2"]include_upstream=False => ["task_2"]include_direct_upstream=True => ["task_2", "task_skip", "task_one_success", "task_1"]So the final


partial_dagis["task_2", "task_skip", "task_one_success", "task_1"]This partial_dag is incomplete because
task_one_success's other upstream nodetask_runis not in it.Specifically, theinclude_upstreamparameter should not be falseSolution
The correct subgraph division should be as follows,
include_upstream=True:task => "task_1"task.downstream_task_ids => "task_2"include_downstream=True => ["task_2"]include_upstream=True =>["task_2", "task_skip", "task_one_success", "task_1", "task_run", "branch"]include_direct_upstream=True => ["task_2", "task_skip", "task_one_success", "task_1", "task_run", "branch"]So the final partial_dag is
["task_2", "task_skip", "task_one_success", "task_1", "task_run", "branch"]The final partial_dag should be as follows:


Subgraph pruning will only be performed when the
schedule_after_task_executionparameter is turned on. Normal scheduler scheduling will not have this problem.