This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 7bb1d4a117 Use class-bound attribute directly in SA `lazyload` (#39195)
7bb1d4a117 is described below
commit 7bb1d4a11752423e63609d237092aa1152b4912b
Author: Andrey Anshin <[email protected]>
AuthorDate: Tue Apr 23 14:01:42 2024 +0400
Use class-bound attribute directly in SA `lazyload` (#39195)
---
airflow/jobs/scheduler_job_runner.py | 2 +-
airflow/models/taskinstance.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/airflow/jobs/scheduler_job_runner.py
b/airflow/jobs/scheduler_job_runner.py
index 2d2c657dac..631de5692e 100644
--- a/airflow/jobs/scheduler_job_runner.py
+++ b/airflow/jobs/scheduler_job_runner.py
@@ -1631,7 +1631,7 @@ class SchedulerJobRunner(BaseJobRunner, LoggingMixin):
query = (
select(TI)
- .options(lazyload("dag_run")) # avoids double join to
dag_run
+ .options(lazyload(TI.dag_run)) # avoids double join
to dag_run
.where(TI.state.in_(State.adoptable_states))
.join(TI.queued_by_job)
.where(Job.state.is_distinct_from(JobState.RUNNING))
diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index b4d5d5d65a..cb071e2edc 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -1854,7 +1854,7 @@ class TaskInstance(Base, LoggingMixin):
) -> TaskInstance | TaskInstancePydantic | None:
query = (
session.query(TaskInstance)
- .options(lazyload("dag_run")) # lazy load dag run to avoid
locking it
+ .options(lazyload(TaskInstance.dag_run)) # lazy load dag run to
avoid locking it
.filter_by(
dag_id=dag_id,
run_id=run_id,