question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

on_success_callback isn't run when marking a task instance as successful when it's not in a running state

See original GitHub issue

Apache Airflow version

2.2.3

What happened

When a task instance is in a failed state (or any other non running state), and then it’s marked as successful through the UI, the on_success_callback set on the task instance is not run.

What you think should happen instead

The on_success_callback should run when marking a task instance successful from the UI regardless of its state.

How to reproduce

  1. Create a DAG
  2. Add a task with an on_success_callback that throws an exception (so it fails)
  3. Run the DAG in the UI
  4. Wait for the task instance to fail for that DAG run
  5. Mark the task instance successful in the UI for that DAG run

Operating System

Debian 10 (Buster)

Versions of Apache Airflow Providers

apache-airflow-providers-databricks==2.5.0

This is the main provider we care about at the moment.

Deployment

Other Docker-based deployment

Anything else

From my observations, it seems as though the on_success_callback is run when a task instance is in a RUNNING state, and then is marked successful from the UI, but not when the task instance is in any other state. From some brief digging this behaviour appears to be related to the heartbeat_callback based on this old bug report but I can’t see any equivalent logic for when the task isn’t running.

For context - we are using this behaviour to track issues occurring in Airflow with a 3rd party tool where marking a task instance as successful is effectively an “ignore”, and our on_success_callback lets us register that ignore to another tool that tracks alerting.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tirkarthicommented, Apr 13, 2022

This seems to be a duplicate of https://github.com/apache/airflow/issues/18113

0reactions
lukeknxtcommented, Apr 14, 2022

@tirkarthi ,

Yep that looks like the same issue.

Based on what @andrewgodwin said in #18113, it looks like this type of thing could be done in the future via running callback-only workloads on executors, but right now it doesn’t seem like a change that’d be easy to add.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bet you didn't know this about Airflow! | by Jyoti Dhiman
Working with task callbacks in Airflow ... the state of this task indicates whether the job is in the running/successful or failed state....
Read more >
DAG marked as "success" if one task fails, because of trigger ...
I thought it was an interesting question and spent some time figuring out how to achieve it without an extra dummy task.
Read more >
Callbacks — Airflow Documentation
Callback functions are only invoked when the task state changes due to execution by a worker. As such, task changes set by the...
Read more >
on_failure_callback does not seem to fire on pod deletion ...
The fix I provided resolved it but I'm close to getting another one out. When the pod is killed, the task instance state...
Read more >
How to use manual jobs with `needs:` relationships - GitLab
The job gets added to the pipeline, but doesn't run until you click ... then the pipeline does not care if the job...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found