This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit a522e378e0b1a618c97139b37f7385dc130acb44
Author: Daniel Standish <[email protected]>
AuthorDate: Thu Apr 24 10:19:59 2025 -0700

    Remove reference to root_dag_id in dagbag and restore logic (#49668)
    
    Also I think that we used to remove the dag in queston from the dagbag when 
expired.
    
    (cherry picked from commit d12072959b5040b6c0ef2e09da4ca25d1545efa2)
---
 airflow-core/src/airflow/models/dagbag.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/airflow-core/src/airflow/models/dagbag.py 
b/airflow-core/src/airflow/models/dagbag.py
index 977875b90f0..52c2337474d 100644
--- a/airflow-core/src/airflow/models/dagbag.py
+++ b/airflow-core/src/airflow/models/dagbag.py
@@ -235,23 +235,21 @@ class DagBag(LoggingMixin):
 
         # If asking for a known subdag, we want to refresh the parent
         dag = None
-        root_dag_id = dag_id
         if dag_id in self.dags:
             dag = self.dags[dag_id]
 
         # If DAG Model is absent, we can't check last_expired property. Is the 
DAG not yet synchronized?
-        orm_dag = DagModel.get_current(root_dag_id, session=session)
+        orm_dag = DagModel.get_current(dag_id, session=session)
         if not orm_dag:
             return self.dags.get(dag_id)
 
-        # If the dag corresponding to root_dag_id is absent or expired
-        is_missing = root_dag_id not in self.dags
+        is_missing = dag_id not in self.dags
         is_expired = (
             orm_dag.last_expired and dag and dag.last_loaded and 
dag.last_loaded < orm_dag.last_expired
         )
         if is_expired:
             # Remove associated dags so we can re-add them.
-            self.dags = {key: dag for key, dag in self.dags.items()}
+            self.dags.pop(dag_id, None)
         if is_missing or is_expired:
             # Reprocess source file.
             found_dags = self.process_file(

Reply via email to