File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
python_modules/dagster/dagster/_core/execution Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 2626from dagster ._core .storage .dagster_run import (
2727 CANCELABLE_RUN_STATUSES ,
2828 NOT_FINISHED_STATUSES ,
29+ DagsterRunStatus ,
2930 RunsFilter ,
3031)
3132from dagster ._core .storage .tags import BACKFILL_ID_TAG , USER_TAG
@@ -557,18 +558,32 @@ def cancel_backfill_runs_and_cancellation_complete(
557558
558559 while True :
559560 # Cancel all cancelable runs for the backfill in batches
561+
562+ # start with the queued runs since those will be faster to cancel
560563 runs_to_cancel_in_iteration = instance .run_storage .get_runs (
561564 filters = RunsFilter (
562- statuses = CANCELABLE_RUN_STATUSES ,
565+ statuses = [ DagsterRunStatus . QUEUED ] ,
563566 tags = {
564567 BACKFILL_ID_TAG : backfill_id ,
565568 },
566569 ),
567570 limit = CANCELABLE_RUNS_BATCH_SIZE ,
568571 ascending = True ,
569572 )
573+
570574 if not runs_to_cancel_in_iteration :
571- break
575+ runs_to_cancel_in_iteration = instance .run_storage .get_runs (
576+ filters = RunsFilter (
577+ statuses = CANCELABLE_RUN_STATUSES ,
578+ tags = {
579+ BACKFILL_ID_TAG : backfill_id ,
580+ },
581+ ),
582+ limit = CANCELABLE_RUNS_BATCH_SIZE ,
583+ ascending = True ,
584+ )
585+ if not runs_to_cancel_in_iteration :
586+ break
572587
573588 canceled_any_runs = True
574589 for run in runs_to_cancel_in_iteration :
You can’t perform that action at this time.
0 commit comments