nailo2c commented on code in PR #68139:
URL: https://github.com/apache/airflow/pull/68139#discussion_r3642864904


##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -1198,6 +1201,61 @@ def _emit_dagrun_span(self, state: DagRunState):
             span.set_status(status_code)
             span.end()
 
+    def get_task_group_retry_count(self, group_id: str) -> int:
+        """Return how many times ``group_id`` has been retried as a unit in 
this run."""
+        return (self.task_group_retries or {}).get(group_id, 0)
+
+    def increment_task_group_retry_count(self, group_id: str) -> int:
+        """Bump and return the unit-retry counter for ``group_id`` in this 
run."""
+        counters = dict(self.task_group_retries or {})
+        counters[group_id] = counters.get(group_id, 0) + 1
+        self.task_group_retries = counters
+        return counters[group_id]
+
+    def _handle_task_group_retries(self, dag: SerializedDAG, *, session: 
Session) -> None:
+        """Clear and re-run any retryable TaskGroup that has a failed task and 
still has retries left."""
+        from airflow.models.taskinstance import clear_task_instances
+
+        retryable_groups = [
+            group for group in dag.task_group.get_task_group_dict().values() 
if group.retries > 0
+        ]
+        if not retryable_groups:
+            return
+
+        # Not-yet-started members are skipped, since clearing them records 
spurious history rows.
+        clearable_states = State.finished | {TaskInstanceState.RUNNING, 
TaskInstanceState.RESTARTING}

Review Comment:
   Why does clearable_states only cover these states? What happens if a member 
is in `TaskInstanceState.DEFERRED` (or others) when the group retries?



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