Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions airflow-core/src/airflow/models/backfill.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ def _create_backfill_dag_run(
return
lock = session.execute(
with_row_locks(
query=select(DagRun).where(DagRun.logical_date == info.logical_date),
query=select(DagRun).where(
DagRun.logical_date == info.logical_date,
DagRun.dag_id == dag.dag_id,
),
session=session,
skip_locked=True,
)
Expand Down Expand Up @@ -410,7 +413,7 @@ def _handle_clear_run(session, dag, dr, info, backfill_id, sort_ordinal):
# Update backfill_id and run_type in DagRun table
session.execute(
update(DagRun)
.where(DagRun.logical_date == info.logical_date)
.where(DagRun.logical_date == info.logical_date, DagRun.dag_id == dag.dag_id)
.values(
backfill_id=backfill_id,
run_type=DagRunType.BACKFILL_JOB,
Expand Down
2 changes: 1 addition & 1 deletion airflow-core/tests/unit/models/test_backfill.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def test_reprocess_behavior(reprocess_behavior, num_in_b, exc_reasons, dag_maker
query = (
select(DagRun)
.join(BackfillDagRun.dag_run)
.where(BackfillDagRun.backfill_id == b.id)
.where(BackfillDagRun.backfill_id == b.id, DagRun.dag_id == dag.dag_id)
.order_by(BackfillDagRun.sort_ordinal)
)
# these are all the dag runs that are part of this backfill
Expand Down