Skip to content

Conversation

@tirkarthi
Copy link
Contributor

  • Don't clear status when a task is marked as failure with downstream selected since marking it failure and again clearing status will re-run the tasks again.
  • When a task that is already failed is again marked as failure even without downstream not being selected then don't clear the status of downstream tasks.

closes: #22995
related: #22995

@boring-cyborg boring-cyborg bot added the area:webserver Webserver related Issues label Apr 19, 2022
@tirkarthi
Copy link
Contributor Author

Test case and end result for the change.

 with DAG("test_mark_task_instance_state_failed_downstream_clear", start_date=start_date) as dag:
    task_1 = EmptyOperator(task_id="task_1")  
    task_2 = EmptyOperator(task_id="task_2")
    task_3 = EmptyOperator(task_id="task_3")                                                                                                                          

    task_1 >> task_2 >> task_3 

Mark task_1 as Failed with Downstream True

Task Start state End state
task_1 Success Failed
task_2 Success Failed
task_3 Success Failed
Task Start state End state
task_1 Success Failed
task_2 Success Failed
task_3 Failed Failed

Mark task_1 as Failed with Downstream False

Task Start state End state
task_1 Success Failed
task_2 Success Success
task_3 Failed None
Task Start state End state
task_1 Failed Failed
task_2 Success Success
task_3 Failed Failed
Task Start state End state
task_1 Success Failed
task_2 Success Success
task_3 Success Success

@ashb
Copy link
Member

ashb commented Apr 22, 2022

Haven't looked at tests (I'm on mobile so I can't read them easily) but the code change makes sense

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this one become none?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to ensure the behavior in #13037 is kept in place. I also find it slightly counter intuitive since downstream is not selected and marking a task as failure shouldn't clear the state of downstream tasks that are failed already for re-run. Should we change it so that failed state is preserved?

@tirkarthi tirkarthi force-pushed the fix-task-clear-mark-fail branch 2 times, most recently from 816a05f to a9b47f3 Compare April 26, 2022 10:51
Copy link
Contributor

@bbovenzi bbovenzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing locally. This looks good to me.

@bbovenzi bbovenzi added this to the Airflow 2.3.1 milestone May 13, 2022
@github-actions
Copy link

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label May 13, 2022
@tirkarthi tirkarthi force-pushed the fix-task-clear-mark-fail branch from a9b47f3 to 8592a20 Compare May 16, 2022 17:22
Comment on lines +2432 to +2979
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right. task2 and task3 should either be left as success, or changed to upstream failed. I don't think failed is right though...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current behavior is that setting a task instance as Failure with downstream=True results in clearing the downstream tasks that are rerun to be set as upstream failed. The reported issue #22995 expects the downstream tasks also to be set as failure rather than being cleared for re-run.

The behavior was introduced in #13037 where task marked as success cleared downstream tasks for re-run. When the task is marked as failure with downstream=True should we clear for re-run or should we set it to failure?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My 2c is it needs to be consistent. If we like the "success + downstream" clearing downstream behavior, it should do the same thing with "failed + downstream".

So I think the current behavior is correct, but I think the dialog could be refactored to indicate that the downstreams are cleared.

And here is a reason you'd want clearing instead of just setting everything to failed. What if you have tasks with one_failed or all_failed as a trigger rule downstream? Forcing everything downstream as failed assumes all_success...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this in test_views.py? All the mark functions in views.py do is call dag.set_task_instance_state and then redirect. Nothing should be tested in views for this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is test_mark_task_instance_state which had tests for marking instance state. I thought to add them here since the original issue was about marking it through API. Do you want me to move it to tests/models/test_dag.py ?

@itstalmeez
Copy link

Resolves issue #22995 by preventing the clearing of task status when marking a task as failed with downstream selected. This adjustment is crucial to avoid unintended task reruns. Previously, marking a task as failed with downstream selected resulted in both marking it as failed and subsequently clearing its status, causing unnecessary task reruns.

Additionally, in cases where a task is already in a failed state and is marked as failed again without downstream selected, this fix ensures that the status of downstream tasks is not cleared. This behavior ensures consistency in handling task status, preventing unnecessary resets when not explicitly intended.

Your feedback on this improvement is appreciated. Please review and share any insights. This change is closely related to the ongoing efforts to enhance task status management, as noted in issue #22995. Thank you for your attention to these considerations.

@potiuk
Copy link
Member

potiuk commented Dec 6, 2023

Resolves issue #22995 by preventing the clearing of task status when marking a task as failed with downstream selected. This adjustment is crucial to avoid unintended task reruns. Previously, marking a task as failed with downstream selected resulted in both marking it as failed and subsequently clearing its status, causing unnecessary task reruns.

Additionally, in cases where a task is already in a failed state and is marked as failed again without downstream selected, this fix ensures that the status of downstream tasks is not cleared. This behavior ensures consistency in handling task status, preventing unnecessary resets when not explicitly intended.

Your feedback on this improvement is appreciated. Please review and share any insights. This change is closely related to the ongoing efforts to enhance task status management, as noted in issue #22995. Thank you for your attention to these considerations.

Please stop posting chat-gpt / AI generated comments. They are nonsencial, useless and bring no value for anyone @itstalmeez . I was tempted to report you to Github which might result in your account being suspended, but for a while I decided to hold on to see if warning like that will be efficient.

This adds a lot of noise to communication here and you are spamming our project. One more time and report will be sent.

bbovenzi

This comment was marked as duplicate.

Copy link
Contributor

@bbovenzi bbovenzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase needed.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Apr 22, 2024
@github-actions github-actions bot closed this Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webserver Webserver related Issues full tests needed We need to run full set of tests for this PR to merge stale Stale PRs per the .github/workflows/stale.yml policy file type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

when trying to mark downstream tasks as failed in the UI tasks are instead cleared and reran

9 participants