diff --git a/python_modules/dagster/dagster/_core/storage/runs/sql_run_storage.py b/python_modules/dagster/dagster/_core/storage/runs/sql_run_storage.py index 0b81bfd70fc42..a357c7cde3f9a 100644 --- a/python_modules/dagster/dagster/_core/storage/runs/sql_run_storage.py +++ b/python_modules/dagster/dagster/_core/storage/runs/sql_run_storage.py @@ -1026,8 +1026,7 @@ def update_backfill(self, partition_backfill: PartitionBackfill) -> None: def delete_backfill(self, backfill_id: str) -> None: check.str_param(backfill_id, "backfill_id") runs_in_backfill = self.get_run_ids(filters=RunsFilter.for_backfill(backfill_id)) - for run_id in runs_in_backfill: - self.delete_run(run_id) + self.delete_runs(runs_in_backfill) query = db.delete(BulkActionsTable).where(BulkActionsTable.c.key == backfill_id) with self.connect() as conn: conn.execute(query) diff --git a/python_modules/dagster/dagster_tests/storage_tests/utils/run_storage.py b/python_modules/dagster/dagster_tests/storage_tests/utils/run_storage.py index 6c0696c66232b..6d8d51b04a5bd 100644 --- a/python_modules/dagster/dagster_tests/storage_tests/utils/run_storage.py +++ b/python_modules/dagster/dagster_tests/storage_tests/utils/run_storage.py @@ -1808,14 +1808,15 @@ def test_delete_backfill(self, storage: RunStorage): backfill_timestamp=time.time(), ) storage.add_backfill(two) - storage.add_run( - TestRunStorage.build_run( - run_id=make_new_run_id(), - job_name="some_pipeline", - status=DagsterRunStatus.SUCCESS, - tags={BACKFILL_ID_TAG: two.backfill_id}, + for _ in range(3): + storage.add_run( + TestRunStorage.build_run( + run_id=make_new_run_id(), + job_name="some_pipeline", + status=DagsterRunStatus.SUCCESS, + tags={BACKFILL_ID_TAG: two.backfill_id}, + ) ) - ) storage.add_run( TestRunStorage.build_run( @@ -1831,7 +1832,7 @@ def test_delete_backfill(self, storage: RunStorage): assert storage.get_backfill("two").backfill_id == "two" - assert len(storage.get_runs()) == 2 + assert len(storage.get_runs()) == 4 storage.delete_backfill("two") assert storage.get_backfill("two") is None assert len(storage.get_runs()) == 1