jedcunningham commented on code in PR #30375:
URL: https://github.com/apache/airflow/pull/30375#discussion_r1166348443


##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1425,6 +1465,51 @@ def _send_sla_callbacks_to_processor(self, dag: DAG) -> 
None:
         )
         self.job.executor.send_callback(request)
 
+    @provide_session
+    def _fail_tasks_stuck_in_queued(self, session: Session = NEW_SESSION) -> 
None:
+        """
+        Mark tasks stuck in queued for longer than `task_queued_timeout` as 
failed.
+
+        Tasks can get stuck in queued for a wide variety of reasons (e.g. 
celery loses
+        track of a task, a cluster can't further scale up its workers, etc.), 
but tasks
+        should not be stuck in queued for a long time. This will mark tasks 
stuck in
+        queued for longer than `self._task_queued_timeout` as failed. If the 
task has
+        available retries, it will be retried.
+        """
+        self.log.debug("Calling SchedulerJob._fail_tasks_stuck_in_queued 
method")
+
+        if type(self.job.executor).cleanup_stuck_queued_tasks == 
BaseExecutor.cleanup_stuck_queued_tasks:
+            self.log.debug("Executor doesn't support cleanup of stuck queued 
tasks. Skipping.")
+            return
+
+        for attempt in run_with_db_retries(logger=self.log):
+            with attempt:
+                self.log.debug(
+                    "Running SchedulerJob._fail_tasks_stuck_in_queued with 
retries. Try %d of %d",
+                    attempt.retry_state.attempt_number,
+                    MAX_DB_RETRIES,
+                )

Review Comment:
   I removed this.



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to