Skip to content

Commit

Permalink
Add back join to zombie query that was dropped in apache#28198 (apach…
Browse files Browse the repository at this point in the history
…e#28544)

apache#28198 accidentally dropped a join in a query, leading to this:

    airflow/jobs/scheduler_job.py:1547 SAWarning: SELECT statement has a
    cartesian product between FROM element(s) "dag_run_1", "task_instance",
    "job" and FROM element "dag". Apply join condition(s) between each element to resolve.

(cherry picked from commit a24d18a)
  • Loading branch information
jedcunningham authored and shinny-taojiachun committed Apr 2, 2024
1 parent 0fe76f6 commit 720d2d0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion airflow/jobs/scheduler_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,8 @@ def _find_zombies(self) -> None:
zombies: list[tuple[TI, str, str]] = (
session.query(TI, DM.fileloc, DM.processor_subdir)
.with_hint(TI, "USE INDEX (ti_state)", dialect_name="mysql")
.join(LocalTaskJob, TaskInstance.job_id == LocalTaskJob.id)
.join(LocalTaskJob, TI.job_id == LocalTaskJob.id)
.join(DM, TI.dag_id == DM.dag_id)
.filter(TI.state == TaskInstanceState.RUNNING)
.filter(
or_(
Expand Down

0 comments on commit 720d2d0

Please sign in to comment.