phanikumv commented on code in PR #69248:
URL: https://github.com/apache/airflow/pull/69248#discussion_r3518481467


##########
airflow-core/src/airflow/models/taskinstancehistory.py:
##########
@@ -211,8 +211,11 @@ def record_ti(ti: TaskInstance, *, session: Session = 
NEW_SESSION) -> None:
         ti_history_state = ti.state
         if ti.state not in State.finished:
             ti_history_state = TaskInstanceState.FAILED
-            ti.end_date = timezone.utcnow()
-            ti.set_duration()
+            # Callers that know when the try actually ended (e.g. the 
Execution API
+            # retry path) pre-set end_date; only stamp archive time when unset.
+            if ti.end_date is None:
+                ti.end_date = timezone.utcnow()
+                ti.set_duration()

Review Comment:
   Since this converted an unconditional stamp into a conditional one, could 
you add a test for the fallback branch -does a TI with end_date=None going 
through record_ti (non-finished state) still get a non-NULL end_date/duration 
archived? 
   
   The retry test can't reach it because `TIRetryStatePayload.end_date` is 
required, so it'd go through the clear/prepare_db_for_next_try path



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