Uh oh!
There was an error while loading. Please reload this page.
fix schedule_downstream_tasks bug - #42582
Conversation
romsharon98
commented
Sep 30, 2024
Can you add test that prevent regression? |
Thank you for the suggestion. I've added test to prevent regression. Please check the latest commit. |
Uh oh!
There was an error while loading. Please reload this page.
luoyuliuyin
commented
Oct 10, 2024
Uh oh!
There was an error while loading. Please reload this page.
Also, DB tests currently fail |
shahar1
left a comment
There was a problem hiding this comment.
LGTM - I'm ok with merging it after resolving my last nitpick.
@potiuk / @uranusjr / @ephraimbuddy - any objections?
Uh oh!
There was an error while loading. Please reload this page.
potiuk
commented
Oct 14, 2024
* 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.