feat(dag_command.py): change to use bulk clear#68280
Merged
Merged
Conversation
FrankYang0529
requested review from
bugraoz93,
dheerajturaga and
potiuk
as code owners
June 9, 2026 11:43
FrankYang0529
marked this pull request as draft
June 9, 2026 11:44
Lee-W
reviewed
Jun 9, 2026
FrankYang0529
force-pushed
the
airflow-67484
branch
from
June 10, 2026 10:50
995b70d to
53e15dc
Compare
FrankYang0529
marked this pull request as ready for review
June 10, 2026 12:32
Lee-W
self-requested a review
June 10, 2026 14:28
Lee-W
reviewed
Jun 11, 2026
FrankYang0529
force-pushed
the
airflow-67484
branch
from
June 11, 2026 12:32
53e15dc to
0a36b74
Compare
Lee-W
approved these changes
Jun 11, 2026
Signed-off-by: PoAn Yang <payang@apache.org>
Signed-off-by: PoAn Yang <payang@apache.org>
Signed-off-by: PoAn Yang <payang@apache.org>
imrichardwu
pushed a commit
to imrichardwu/airflow
that referenced
this pull request
Jun 16, 2026
dingo4dev
pushed a commit
to dingo4dev/airflow
that referenced
this pull request
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes: #67484
Why
airflow dags clear(#66004) loopsdag.clear(run_id=...)once per matched run, issuing a separate SELECT + flush for each. A wide--partition-date-*window or broad--partition-keytherefore costs N independent transactions.How
Replace the per-run loop with a
_bulk_clear_runshelper:run_idsin chunks of_RUN_CHUNK_SIZE (500), fetching all matching TIs for each chunk with a single query.clear_task_instancesin one call.Two new tests:
test_clears_multiple_runs_in_one_batch: asserts that 3 runs fitting in one chunk result in exactly oneclear_task_instancescall.test_chunks_on_run_boundaries_clears_each_run_once: patches_RUN_CHUNK_SIZEto 2. 3 runs span 2 chunks.Was generative AI tooling used to co-author this PR?
Claude Code with Claude Opus 4.8
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.