The GitHub Actions job "Tests AMD" on airflow.git/v3-0-test has failed. Run started by GitHub user kaxil (triggered by kaxil).
Head commit for run: 364d2468a18defafadeadffe18e73b8848a6112c / Kaxil Naik <kaxiln...@gmail.com> Fix `DetachedInstanceError` when accessing `DagRun.created_dag_version` (#54362) The error occurred when trying to access `dag_run.created_dag_version` on a DagRun object that was detached from its SQLAlchemy session. Stacktrace: ``` [2025-08-08T19:03:28.761+0000] {scheduler_job_runner.py:935} ERROR - Marking task instance <TaskInstance: sell_oms_shipconfirm_mao_to_ecom_load_delta_quarterly.shipconfirm_delta_to_kafka_notebook_task scheduled__2025-08-08T07:30:00+00:00 [running]> as failed Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/airflow/jobs/scheduler_job_runner.py", line 925, in process_executor_events dag = scheduler_dag_bag.get_dag(dag_run=ti.dag_run, session=session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/airflow/jobs/scheduler_job_runner.py", line 141, in get_dag version = self._version_from_dag_run(dag_run=dag_run, session=session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/airflow/jobs/scheduler_job_runner.py", line 135, in _version_from_dag_run dag_version = dag_run.created_dag_version ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 487, in __get__ return self.impl.get(state, dict_) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 959, in get value = self._fire_loader_callables(state, key, passive) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 995, in _fire_loader_callables return self.callable_(state, passive) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/strategies.py", line 863, in _load_for_state raise orm_exc.DetachedInstanceError( sqlalchemy.orm.exc.DetachedInstanceError: Parent instance <DagRun at 0x7f46d309a5d0> is not bound to a Session; lazy load operation of attribute 'created_dag_version' cannot proceed (Background on this error at: https://sqlalche.me/e/14/bhk3) ``` Two-layer fix: 1. Proactive loading: Add `selectinload` for `created_dag_version` in `process_executor_events` query to ensure optimal performance for this critical path 2. Defensive code: Add relationship loading check in `DBDagBag._version_from_dag_run` to handle all call sites safely using SQLAlchemy inspect pattern (cherry picked from commit 05d2229d0e1b3aeec7b196ef007384d16350f3a1) Report URL: https://github.com/apache/airflow/actions/runs/16887919085 With regards, GitHub Actions via GitBox --------------------------------------------------------------------- To unsubscribe, e-mail: jobs-unsubscr...@airflow.apache.org For additional commands, e-mail: jobs-h...@airflow.apache.org