manipatnam commented on code in PR #72054:
URL: https://github.com/apache/airflow/pull/72054#discussion_r4749455670


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/backfills.py:
##########
@@ -247,6 +247,12 @@ def cancel_backfill(backfill_id: NonNegativeInt, session: 
SessionDep) -> Backfil
         raise HTTPException(status.HTTP_404_NOT_FOUND, BACKFILL_NOT_FOUND)
     if b.completed_at is not None:
         raise HTTPException(status.HTTP_409_CONFLICT, "Backfill is already 
completed.")
+    # The backfill row is committed before its Dag runs and associations are 
created. Cancelling
+    # in that window would fail no runs, and the runs would later start under 
a completed backfill.
+    if not session.scalar(select(exists().where(BackfillDagRun.backfill_id == 
b.id))):

Review Comment:
   Agreed, the sweep can't tell a slow creation from a failed one because it 
can't see the uncommitted associations. A separate issue makes sense to me: the 
fix belongs in how a backfill signals that creation has finished, for example 
an "initialized" marker committed together with the runs, which both the sweep 
and cancel could check instead of inferring it from associations and age. I've 
noted the limitation in the PR description for now. Happy to open the issue.



-- 
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]

Reply via email to