airflow-ctl-tests: wait for Dag run terminal state before xcom commands#67065
Merged
Conversation
The airflowctl xcom integration tests are flaky on ARM CI: xcom add plus xcom get and xcom list succeed, then xcom edit and xcom delete fail with "The XCom with key ... doesn't exist". Same SHA passes on some ARM runs and fails on others. Root cause is a race between the test's xcom add and execution of runme_0. When the task transitions to RUNNING, the execution API queries every XCom key for that task instance and tells the worker to clear them via xcom_keys_to_clear (see airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py and task-sdk/src/airflow/sdk/execution_time/task_runner.py). If the xcom add lands before the task starts running -- which only takes a few seconds for the bash echo task in example_bash_operator -- the user-added XCom is wiped right before xcom edit / xcom delete fires. Wait for the targeted Dag run to reach a terminal state before each xcom command. Once the task is terminal it won't run again, so the clear logic doesn't fire and the user-added XCom survives the rest of the xcom commands.
jscheffl
approved these changes
May 17, 2026
Member
Author
|
I'd love to get this one merged — and would love it in 3.2.2 if it's not too late. cc @vatsrahul1001 (3.2.2 RM) Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting |
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.
The airflowctl xcom integration tests are flaky on ARM CI:
xcom addplusxcom getandxcom listsucceed, thenxcom editandxcom deletefailwith
"The XCom with key … doesn't exist". Same SHA passes on some ARM runsand fails on others.
Root cause is a race between the test's
xcom addand execution ofrunme_0. When the task transitions to RUNNING, the execution API queriesevery XCom key currently stored for that task instance and tells the worker
to clear them via
xcom_keys_to_clear(seeairflow-core/.../execution_api/routes/task_instances.py:264-275and
task-sdk/.../execution_time/task_runner.py:1262-1270).If
xcom addlands before the task starts running — which only takes a fewseconds for the bash echo task in
example_bash_operator— the user-addedXCom is wiped right before
xcom edit/xcom deletefires.Fix: wait for the targeted Dag run to reach a terminal state
(
success/failed) before eachxcomcommand. Once the task is terminal itwon't run again, so the clear logic doesn't fire and the user-added XCom
survives the rest of the xcom commands.
Observed failing CI run: https://github.com/apache/airflow/actions/runs/25981599655/job/76374215829
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 4.7 (1M context) following the guidelines