1fanwang commented on code in PR #66767:
URL: https://github.com/apache/airflow/pull/66767#discussion_r3493222042


##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -3530,12 +3530,22 @@ def _purge_task_instances_without_heartbeats(
             # Backfill dag_version_id for legacy tasks (Pydantic requires 
uuid.UUID).
             if not _ensure_ti_has_dag_version_id(ti, session, self.log):
                 continue
+            # ``_purge_task_instances_without_heartbeats`` doesn't load 
``ti.task``, so
+            # ``ti.is_eligible_to_retry()`` takes a fallback branch that 
misclassifies
+            # tasks declared with ``retries=0`` as retry-eligible. Decide 
directly from
+            # ``max_tries`` and ``try_number`` to match the "task loaded" 
branch instead.

Review Comment:
   Done in 70eef3c9b9 — switched to ti.max_tries > 0 and 
ti.is_eligible_to_retry().



##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -3530,12 +3530,22 @@ def _purge_task_instances_without_heartbeats(
             # Backfill dag_version_id for legacy tasks (Pydantic requires 
uuid.UUID).
             if not _ensure_ti_has_dag_version_id(ti, session, self.log):
                 continue
+            # ``_purge_task_instances_without_heartbeats`` doesn't load 
``ti.task``, so
+            # ``ti.is_eligible_to_retry()`` takes a fallback branch that 
misclassifies
+            # tasks declared with ``retries=0`` as retry-eligible. Decide 
directly from
+            # ``max_tries`` and ``try_number`` to match the "task loaded" 
branch instead.

Review Comment:
   For RESTARTING: confirmed the purge query selects RUNNING/RESTARTING, so 
it's reachable here. The old try_number <= max_tries form marked a 
cleared-while-running TI past max_tries as FAILED; deferring to the predicate 
keeps it UP_FOR_RETRY. Added a parametrized 
restarting_stays_eligible_past_max_tries case that fails on the old form.



-- 
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]

Reply via email to