uranusjr commented on code in PR #63719:
URL: https://github.com/apache/airflow/pull/63719#discussion_r3494417333


##########
task-sdk/src/airflow/sdk/execution_time/task_runner.py:
##########
@@ -1761,11 +1761,19 @@ def finalize(
 
     if getattr(ti.task, "overwrite_rtif_after_execution", False):
         log.debug("Overwriting Rendered template fields.")
-        if ti.task.template_fields:
-            try:
-                
SUPERVISOR_COMMS.send(SetRenderedFields(rendered_fields=_serialize_rendered_fields(ti.task)))
-            except Exception:
-                log.exception("Failed to set rendered fields during 
finalization", ti=ti, task=ti.task)
+        # Only update RTIF for terminal states. RTIF table doesn't have 
try_number column,
+        # so intermediate states (UP_FOR_RETRY, UP_FOR_RESCHEDULE, DEFERRED) 
would just
+        # overwrite each other. We only store the terminal state attempt's 
rendered fields.
+        if state in (TaskInstanceState.SUCCESS, TaskInstanceState.FAILED, 
TaskInstanceState.SKIPPED):
+            if ti.task.template_fields:

Review Comment:
   These two `if`s can be collapsed?
   
   Also probably worth a mention on `UPSTREAM_FAILED` in the comment.



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