Skip to content

Commit

Permalink
Use class-bound attribute directly in SA lazyload (#39195)
Browse files Browse the repository at this point in the history
  • Loading branch information
Taragolis authored Apr 23, 2024
1 parent e3e6776 commit 7bb1d4a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion airflow/jobs/scheduler_job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ def adopt_or_reset_orphaned_tasks(self, session: Session = NEW_SESSION) -> int:

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))
Expand Down
2 changes: 1 addition & 1 deletion airflow/models/taskinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ def get_task_instance(
) -> 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,
Expand Down

0 comments on commit 7bb1d4a

Please sign in to comment.