You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cover clearing task state based on dag run clear #72929
#72100 added discard-by-default behavior for task_state_store entries when a task instance
is cleared via the POST /dags/{dag_id}/clearTaskInstances endpoint — checkpoints are
discarded unless keep_task_state is set, so a cleared task starts over instead of silently
resuming from a stale checkpoint after the underlying code/data was fixed.
That fix only applies to that one endpoint. Every other way of clearing a task instance still
keeps task state unconditionally, because each of them calls clear_task_instances() directly
instead of going through the new discard logic:
Clearing an entire Dag run (the "Clear Run" dialog / API) — perform_clear_dag_run -> dag.clear() -> clear_task_instances().
Marking a task as failed/success, which clears downstream tasks as a side effect.
Thread keep_task_state (or an equivalent opt-out) through clear_task_instances() itself, so
every caller (REST endpoint, Dag-run clear, CLI, mark-as-success/failed) converges on the same
discard-by-default behavior. This likely needs:
A keep_task_state parameter on clear_task_instances().
Plumbing it through dag.clear(), perform_clear_dag_run, and the core CLI's airflow dags clear / airflow tasks clear.
Deciding the right default/UX for callers that have no request body to carry the flag today
(e.g. CLI defaults, mark-as-success/failed).
Acceptance criteria
Clearing a Dag run discards task_state_store entries by default, matching the task-instance
clear endpoint, with an equivalent opt-out to keep state.
airflow dags clear / airflow tasks clear behave consistently with the REST endpoints.
Docs (resumable-tasks.rst) no longer need to caveat which clear surface actually discards.
Reproduced on current main: clearing a Dag run leaves its task_state_store checkpoint behind. The new regression fails before the fix, while the existing clear test passes.
A local fix moves deletion into clear_task_instances() and threads the preservation option through single/bulk Dag-run clear and both core CLI clear commands. Tests cover default deletion, explicit preservation, dry-run, untouched scopes, and downstream clearing. The related PostgreSQL suite passed with 1,057 tests; an additional Dag/clear suite passed with 335 tests (the suites overlap).
The patch and PR description are prepared locally; a PR has not been opened yet.
Drafted-by: OpenAI Codex (GPT-6) (no human review before posting)
@amoghrajesh I don't think we should block this on AIP-123. AIP-123 adds a new scope, but this issue is about task state that’s already shipped. Clearing a task instance discards it by default, while clearing a Dag run keeps it. We should be consistent. I’d add keep_task_state to Dag run clear now and let AIP-123 add its own flag for run state.
It’s also going to come up a lot more as we increase coverage with durable operators. Today, clearing a Dag run skips any ResumableJobMixin task whose external job already succeeded, and there’s no way to opt out from the Clear Run dialog.
Activity
yi-wang-ai commentedon Oct 1, 2026
Reproduced on current main: clearing a Dag run leaves its
task_state_storecheckpoint behind. The new regression fails before the fix, while the existing clear test passes.A local fix moves deletion into
clear_task_instances()and threads the preservation option through single/bulk Dag-run clear and both core CLI clear commands. Tests cover default deletion, explicit preservation, dry-run, untouched scopes, and downstream clearing. The related PostgreSQL suite passed with 1,057 tests; an additional Dag/clear suite passed with 335 tests (the suites overlap).The patch and PR description are prepared locally; a PR has not been opened yet.
Drafted-by: OpenAI Codex (GPT-6) (no human review before posting)
amoghrajesh commentedon Oct 5, 2026
Adding a comment here. This is waiting on a draft AIP - AIP-123.
cmarteepants commentedon Nov 9, 2026
@amoghrajesh I don't think we should block this on AIP-123. AIP-123 adds a new scope, but this issue is about task state that’s already shipped. Clearing a task instance discards it by default, while clearing a Dag run keeps it. We should be consistent. I’d add
keep_task_stateto Dag run clear now and let AIP-123 add its own flag for run state.It’s also going to come up a lot more as we increase coverage with durable operators. Today, clearing a Dag run skips any
ResumableJobMixintask whose external job already succeeded, and there’s no way to opt out from the Clear Run dialog.