kaxil commented on a change in pull request #19769: URL: https://github.com/apache/airflow/pull/19769#discussion_r783667980
########## File path: airflow/executors/celery_executor.py ########## @@ -377,6 +385,49 @@ def _check_for_stalled_adopted_tasks(self): for key in timedout_keys: self.change_state(key, State.FAILED) + @provide_session + def _clear_stuck_queued_tasks(self, session: Session = NEW_SESSION) -> None: + """ + Tasks can get stuck in queued state in DB while still not in + worker. This happens when the worker is autoscaled down and + the task is queued but has not been picked up by any worker prior to the scaling. + + In such situation, we update the task instance state to scheduled so that + it can be queued again. We chose to use task_adoption_timeout to decide + """ + if not isinstance(app.backend, DatabaseBackend): + # We only want to do this for database backends where Review comment: Oh yes, atleast in that case, the comment should be clear with a proper TODO or just solved in this PR too for all the other backends. -- 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