dheerajturaga commented on PR #71425:
URL: https://github.com/apache/airflow/pull/71425#issuecomment-6042039512

   On `complete_restart` in `airflow-core/src/airflow/models/taskinstance.py`:
   
   
https://github.com/apache/airflow/blob/e61db15299e619747a4c0b17dd03c3e4c6c22a38/airflow-core/src/airflow/models/taskinstance.py#L1243-L1244
   
   **Minor, and fine to handle in a follow-up PR; it doesn't block this one.**
   
   When a run has been moved to a newer version, the successor now gets that 
version's `dag_version_id`. Both callers of `complete_restart` set `self.task` 
from `get_dag_for_run(ti.dag_run)`, so `max_tries` follows the new version too.
   
   The other task-derived columns don't follow it. `prepare_db_for_next_try` 
copies `queue`, `pool`, `pool_slots`, `priority_weight`, `executor`, 
`executor_config`, `run_as_user` and `operator` from the terminated attempt's 
row. `schedule_tis` only calls `refresh_from_task` for `UP_FOR_RETRY` task 
instances, so a successor in state `None` keeps the old values. If the new 
version moves the task to a different `executor`, `queue` or `pool`, the 
restarted attempt runs the new code with the old routing.
   
   The non-running branch of `clear_task_instances` already handles this with 
`ti.refresh_from_task(task, dag_run=dr)`. Something like this would make the 
two paths match:
   
   ```python
   if self.task is not None:
       successor.refresh_from_task(self.task, dag_run=self.dag_run)
       successor.max_tries = self.try_number + self.task.retries
   ```
   
   ---
   Drafted-by: Claude Code (Opus 5.5); reviewed by @dheerajturaga before posting
   


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