You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clearing a defered task instance in deferred state does not clear its next_method #19612
When I mark a defferd task to Failed-State then clear it or clear a defferd task which in Defferd-State, this task is marked success immediately.
I check the task instance table, this task's next_method is not null when I clear this task.This cause task's execute function is replaced by next_method function.
What you expected to happen
When I clear a defferd task, I want to re-judge it's trigger condition, re-execute the execute function.
classExternalTaskFromOtherAirflowTrigger(BaseTrigger):
def_get_task_instance_state(self):
sql_query="SELECT state FROM {}.task_instance WHERE dag_id = '{}' and run_id like '%{}%';".format(
self.old_airflow_db_name,
self.old_external_dag_id,
self.old_external_task_id,
self.old_external_execution_date_str
)
asyncdefrun(self):
whileself._get_task_instance_state() ==False:
awaitasyncio.sleep(5)
yieldTriggerEvent('success')
Clear this task when it is in defferd State.
Mark this task as failed and clear this task.
Both operations above will cause this task is marked as success instead of re-execute the execute function.
changed the title [-]Clear a deffered task_instance which still in deferred State Do Not clear it's next_method [/-][+]Clearing a defered task instance in deferred state does not clear its next_method[/+]on Nov 17, 2021
Can we reopen this? I just tested the fix in astronomer image 2.3.3-2 and clearing a deferred task will still mark the task as success immediately without executing. The other case of marking the task as failed first then clearing the task does re-execute the task.
After adding this code, In my env, this problem is disappear. of course, I do not use astronomer image 2.3.3-2, I just deploy airflow on host machine. Try to attach into container and check source code sudo docker exec -ti $container_id /bin/bash @park-peter
Activity
boring-cyborg commentedon Nov 16, 2021
Thanks for opening your first issue here! Be sure to follow the issue template!
[-]Clear a deffered task_instance which still in deferred State Do Not clear it's next_method [/-][+]Clearing a defered task instance in deferred state does not clear its next_method[/+]uranusjr commentedon Nov 17, 2021
Your added code makes sense. Feel free to start a pull request for this.
malthe commentedon Feb 2, 2022
We can close this now then right?
jochenott commentedon Jul 8, 2022
I believe this can be closed, as the according code change was made via #23929
uranusjr commentedon Jul 18, 2022
Thanks for catching this
park-peter commentedon Aug 17, 2022
Can we reopen this? I just tested the fix in astronomer image 2.3.3-2 and clearing a deferred task will still mark the task as success immediately without executing. The other case of marking the task as failed first then clearing the task does re-execute the task.
Greetlist commentedon Aug 18, 2022
After adding this code, In my env, this problem is disappear. of course, I do not use
astronomer image 2.3.3-2, I just deploy airflow on host machine. Try to attach into container and check source codesudo docker exec -ti $container_id /bin/bash@park-peteruranusjr commentedon Aug 18, 2022
Should probably do it in a new issue instead with fresh reproduction steps.