ashb commented on code in PR #65932:
URL: https://github.com/apache/airflow/pull/65932#discussion_r3187625999
##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -1993,16 +2003,30 @@ def schedule_tis(
# execute it to run in the worker.
elif not ti.defer_task(session=session):
schedulable_ti_ids.append(ti.id)
- if ti.state == TaskInstanceState.UP_FOR_RESCHEDULE:
+ is_reschedule = ti.state == TaskInstanceState.UP_FOR_RESCHEDULE
+ if is_reschedule:
reschedule_ti_ids.add(ti.id)
if debug_try_number_check:
expected_try_number_by_ti_id[ti.id] = (
- ti.try_number
- if ti.state == TaskInstanceState.UP_FOR_RESCHEDULE
- else ti.try_number + 1,
+ ti.try_number if is_reschedule else ti.try_number + 1,
ti.try_number,
ti.state,
)
+ # Retry-only: first attempts use creation-time hook firing and
+ # reschedules do not bump try_number.
+ if ti.task is not None and ti.state ==
TaskInstanceState.UP_FOR_RETRY:
+ saved_try = ti.try_number
+ saved_values = tuple(getattr(ti, k) for k in
_RETRY_REFRESHED_TI_FIELDS)
+ ti.try_number = saved_try + 1
+ ti.refresh_from_task(ti.task)
+ ti.try_number = saved_try
+ overrides = {
+ k: getattr(ti, k)
+ for k, prev in zip(_RETRY_REFRESHED_TI_FIELDS,
saved_values)
+ if getattr(ti, k) != prev
+ }
+ if overrides:
+ mutated_overrides_by_ti_id[ti.id] = overrides
Review Comment:
This is duplicating the work that SQL does for it's Unit-of-work mechansim.
I don't think we should be doing this ourselves.
Additionally: why do we have a specific list of what fields can be udpated?
What is the thinking there?
--
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]