monroeclinton commented on code in PR #60216:
URL: https://github.com/apache/airflow/pull/60216#discussion_r2672729185
##########
airflow-core/src/airflow/models/backfill.py:
##########
@@ -503,18 +503,25 @@ def _create_backfill(
if no_schedule:
raise DagNoScheduleException(f"{dag_id} has no schedule")
- num_active = session.scalar(
- select(func.count()).where(
+ # Check for overlapping date ranges with active backfills
+ # Two date ranges overlap if: new_from_date <= existing_to_date
+ # AND new_to_date >= existing_from_date
+ overlapping_backfills = session.scalars(
+ select(Backfill).where(
Backfill.dag_id == dag_id,
Backfill.completed_at.is_(None),
+ Backfill.from_date <= to_date,
+ Backfill.to_date >= from_date,
)
- )
Review Comment:
While more expensive than the `count()`, I think it could be worth it for a
UX point of view. If you're trying to create a backfill and it fails, you'll
have to go through the table to figure out which backfill is causing the
failure if it isn't included in the error message. This function is only called
when backfills are created, which shouldn't be terribly frequent. I'd be happy
to revert it to a count if you don't think it's an issue though
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]