xBis7 commented on code in PR #43941:
URL: https://github.com/apache/airflow/pull/43941#discussion_r1886728008
##########
airflow/models/taskinstance.py:
##########
@@ -856,7 +861,14 @@ def _refresh_from_db(
)
if ti:
- _set_ti_attrs(task_instance, ti, include_dag_run=False)
+ inspector = inspect(ti)
+ # Check if the ti is detached or the dag_run relationship isn't loaded.
+ # If the scheduler that started the dag_run has exited (gracefully or
forcefully),
+ # there will be changes to the dag_run span context_carrier.
+ # It's best to include the dag_run whenever possible, so that the ti
will contain the updates.
+ include_dag_run = not inspector.detached and "dag_run" not in
inspector.unloaded
+ log.debug("Unloaded: %s", inspector.unloaded)
Review Comment:
No, it's for including the dag run `include_dag_run`.
Up until last month, there was a check for including the dag_run in certain
conditions
```
_set_ti_attrs(task_instance, ti, include_dag_run=include_dag_run)
```
but it was changed to always `False`
```
_set_ti_attrs(task_instance, ti, include_dag_run=False)
```
With the context propagation changes, it's best to include it whenever
possible so that the task can pick up any changes to the `context_carrier`. If
the carrier has been changed then the task span should use the info from the
new carrier to get properly associated with the parent span.
--
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]