Skip to content

airflow-ctl-tests: wait for Dag run terminal state before xcom commands#67065

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:fix-airflowctl-xcom-race-flake
May 17, 2026
Merged

airflow-ctl-tests: wait for Dag run terminal state before xcom commands#67065
potiuk merged 1 commit into
apache:mainfrom
potiuk:fix-airflowctl-xcom-race-flake

Conversation

@potiuk
Copy link
Copy Markdown
Member

@potiuk potiuk commented May 17, 2026

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 currently stored for that task instance and tells the worker
to clear them via xcom_keys_to_clear (see
airflow-core/.../execution_api/routes/task_instances.py:264-275
and
task-sdk/.../execution_time/task_runner.py:1262-1270).
If 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.

Fix: wait for the targeted Dag run to reach a terminal state
(success/failed) 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.

Observed failing CI run: https://github.com/apache/airflow/actions/runs/25981599655/job/76374215829


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Opus 4.7 (1M context)

Generated-by: Claude Opus 4.7 (1M context) following the guidelines

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.
@potiuk
Copy link
Copy Markdown
Member Author

potiuk commented May 17, 2026

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

@potiuk potiuk merged commit 977935d into apache:main May 17, 2026
83 checks passed
@potiuk potiuk deleted the fix-airflowctl-xcom-race-flake branch May 17, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants