karenbraganz commented on code in PR #53435:
URL: https://github.com/apache/airflow/pull/53435#discussion_r2231810005
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2010,14 +2011,42 @@ def _maybe_requeue_stuck_ti(self, *, ti, session):
"Task requeue attempts exceeded max; marking failed.
task_instance=%s",
ti,
)
+ msg = f"Task was requeued more than
{self._num_stuck_queued_retries} times and will be failed."
session.add(
Log(
event="stuck in queued tries exceeded",
task_instance=ti.key,
- extra=f"Task was requeued more than
{self._num_stuck_queued_retries} times and will be failed.",
+ extra=msg,
)
)
- ti.set_state(TaskInstanceState.FAILED, session=session)
+
+ try:
+ dag = self.scheduler_dag_bag.get_dag(dag_run=ti.dag_run,
session=session)
+ task = dag.get_task(ti.task_id)
+ except Exception:
+ self.log.warning(
+ "The DAG or task could not be found. If a failure callback
exists, it will not be run.",
+ exc_info=True,
+ )
+ else:
+ if task.on_failure_callback:
+ request = TaskCallbackRequest(
+ filepath=ti.dag_model.relative_fileloc,
+ bundle_name=ti.dag_version.bundle_name,
+ bundle_version=ti.dag_version.bundle_version,
+ ti=ti,
+ msg=msg,
+ context_from_server=TIRunContext(
+ dag_run=ti.dag_run,
+ max_tries=ti.max_tries,
+ variables=[],
+ connections=[],
+ xcom_keys_to_clear=[],
+ ),
+ )
+ executor.send_callback(request)
+ finally:
+ ti.set_state(TaskInstanceState.FAILED, session=session)
Review Comment:
Looking into 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]