andrewgodwin commented on a change in pull request #15389:
URL: https://github.com/apache/airflow/pull/15389#discussion_r685279806
##########
File path: airflow/jobs/scheduler_job.py
##########
@@ -1207,3 +1218,26 @@ def adopt_or_reset_orphaned_tasks(self, session: Session
= None):
raise
return len(to_reset)
+
+ @provide_session
+ def check_trigger_timeouts(self, session: Session = None):
+ """
+ Looks at all tasks that are in the "deferred" state and whose trigger
+ or execution timeout has passed, so they can be marked as failed.
+ """
+ num_timed_out_tasks = (
+ session.query(TaskInstance)
+ .filter(TaskInstance.state == State.DEFERRED,
TaskInstance.trigger_timeout < timezone.utcnow())
+ .update(
+ # We have to schedule these to fail themselves so it doesn't
+ # happen inside the scheduler.
+ {
+ "state": State.SCHEDULED,
+ "next_method": "__fail__",
+ "next_kwargs": {"error": "Trigger/execution timeout"},
+ "trigger_id": None,
+ }
+ )
+ )
+ if num_timed_out_tasks:
+ self.log.info("Timed out %i deferred tasks without fired
triggers", num_timed_out_tasks)
Review comment:
Agreed. This isn't the last PR for this, just the first and biggest!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]