Repository navigation
Add example Dag for checkpointing progress from an async task - #71870
Merged
amoghrajesh merged 2 commits intoSep 9, 2026
Merged
Conversation
amoghrajesh
requested review from
guan404ming,
jedcunningham,
kaxil and
vikramkoka
August 20, 2026 07:56
vatsrahul1001
approved these changes
Sep 9, 2026
Contributor
Backport failed to create: v3-3-test. View the failure log Run detailsNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
You can attempt to backport this manually by running: cherry_picker 4b1e9d2 v3-3-testThis should apply the commit to the v3-3-test branch and leave the commit in conflict state marking After you have resolved the conflicts, you can continue the backport process by running: cherry_picker --continueIf you don't have cherry-picker installed, see the installation guide. |
1 task done
vatsrahul1001
added a commit
that referenced
this pull request
Sep 10, 2026
#72840) (cherry picked from commit 4b1e9d2) Co-authored-by: Amogh Desai <[email protected]>
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.
Was generative AI tooling used to co-author this PR?
Adds
example_task_state_store_async.py, showing anasync deftask that fetches pages concurrently and checkpoints its progress withaget/asetso a retry resumes instead of starting over.aget/asetlanded in 3.3 but have no example coverage in the repo, and this is the firstasync deftask inexample_dags/. Two deliberate choices worth calling out for review:The checkpoint is a completed-set, not a high-water cursor. Both async examples in
task-state-store.rsttrack alast_pagecursor, which assumes ordered sequentialcompletion. Under
asyncio.gather, items finish out of order, so a cursor either skipsunfinished work or repeats finished work. A set is correct at any concurrency.
Only the parent coroutine writes the checkpoint. If each worker coroutine did its own
await aset, the writes would interleave at their await points, each overwriting a stalecopy of the set, and completed items would silently vanish. So the task gathers a bounded
batch and the parent checkpoints once per batch. That is the one thing in the file that
gets a comment, because the bug it avoids leaves no trace.
Progress and the running row total live under a single key so one write keeps them
consistent, which also means a resumed attempt does not lose the previous attempt's total.
The staged failure fires only on the first try, so with
retries=2the Dag run demonstrates the resume and still ends successfully on a single trigger.closes: #66842 properly.
Testing
Try 1

Try 2

State store
{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.