dstandish commented on code in PR #39259:
URL: https://github.com/apache/airflow/pull/39259#discussion_r1607061565


##########
airflow/models/taskinstance.py:
##########
@@ -1003,25 +1009,40 @@ def _refresh_from_task(
     task_instance_mutation_hook(task_instance)
 
 
+@internal_api_call
+@provide_session
 def _record_task_map_for_downstreams(
-    *, task_instance: TaskInstance | TaskInstancePydantic, task: Operator, 
value: Any, session: Session
+    *,
+    task_instance: TaskInstance | TaskInstancePydantic,
+    task: Operator,
+    dag: DAG,
+    value: Any,
+    session: Session,
 ) -> None:
     """
     Record the task map for downstream tasks.
 
     :param task_instance: the task instance
     :param task: The task object
+    :param dag: the dag associated with the task
     :param value: The value
     :param session: SQLAlchemy ORM Session
 
     :meta private:
     """
+    # when taking task over RPC, we need to add the dag back
+    if isinstance(task, MappedOperator):
+        if not task.dag:
+            task.dag = dag
+    elif not task._dag:
+        task._dag = dag

Review Comment:
   fyi @uranusjr this is resolved here ([Use sentinel to elide the dag object 
on 
reserialization](https://github.com/apache/airflow/pull/37851/commits/7ba5fc8ac05b2003ef5050f9b13f34e0fdb1ef80))
 but i can't make this PR yet because it's depending on too many other PRs to 
get merged first



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to