Skip to content

Read XCom without object reconstruction during dependency evaluation - #72718

Merged
potiuk merged 3 commits into
apache:mainfrom
potiuk:scheduler-xcom-dep-primitives-only
Oct 19, 2026
Merged

potiuk merged 3 commits into
apache:mainfrom
potiuk:scheduler-xcom-dep-primitives-only

Conversation

@potiuk

@potiuk potiuk commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

The scheduler evaluates task dependencies in-process, and two of those deps read XCom:

  • NotPreviouslySkippedDep reads skipmixin_key for every parent that inherits from SkipMixin — any Branch or ShortCircuit operator, so this is a common path.
  • Both it and TriggerRuleDep read past_depends_met when wait_for_past_depends_before_skipping applies.

Both went through TaskInstance.xcom_pull → XComModel.deserialize_value, which is json.loads(value, cls=XComDecoder). XComDecoder.object_hook calls the serialization module with full=True, so a nested dict carrying __classname__ gets imported and instantiated.

The values these deps actually consume are primitives — a mapping of lists of task ids, and a boolean. Nothing here needs an object rebuilt, so the scheduler can read them as plain JSON without reconstructing objects.

Change

  • XComModel.deserialize_value_primitives — plain json.loads, no object_hook. A __classname__ envelope comes back as a plain dict.
  • LazyXComPrimitivesSelectSequence alongside LazyXComSelectSequence, for the lazy path.
  • full: bool = True threaded through TaskInstance.xcom_pull; full=False at the four dep call sites.

All three of xcom_pull's return paths are covered — the direct one and both lazy-sequence ones. The lazy path is what a mapped task instance takes, so covering only the direct return would have left mapped task instances on the old behaviour.

NotPreviouslySkippedDep also now checks the skipmixin payload is a mapping before testing membership. It reads whatever the parent task wrote, and a scalar there previously raised TypeError inside dependency evaluation instead of being ignored.

Task code pulling another task's return value is unchanged and still receives the original Python object. Only the scheduler-side dep reads are narrowed.

Tests

Two regression tests, both verified to fail on unpatched sources and pass with the change:

  • a serde envelope stored under skipmixin_key is read as a plain mapping rather than reconstructed;
  • a scalar under the same key is ignored rather than raising.

Both write through XComModel.set(..., serialize=False) with a pre-serialized string, which is what the Execution API does with a caller-supplied value — serialize_value would have rejected the payload, so writing through that path would not exercise the case.

Suites run after rebasing on current main: test_not_previously_skipped_dep.py + test_trigger_rule_dep.py + models/test_xcom.py (211), test_taskinstance.py -k xcom (19). All pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_015DKYM5PoVgKC5JqxLso8rn

@potiuk
potiuk requested review from XD-DENG and ashb as code owners September 8, 2026 15:16
@potiuk
potiuk force-pushed the scheduler-xcom-dep-primitives-only branch from e4dd5a2 to 91bc375 Compare September 24, 2026 18:04
@potiuk

potiuk commented Sep 27, 2026

Copy link
Copy Markdown
Member Author

@ashb @XD-DENG — gentle reminder: this needs a review to make the 3.4.0 cut on 2026-10-19. CI is green and it's ready from my side.

@potiuk
potiuk force-pushed the scheduler-xcom-dep-primitives-only branch from 91bc375 to d75eb9a Compare October 4, 2026 23:33
@potiuk
potiuk requested review from amoghrajesh and kaxil October 13, 2026 14:27
The scheduler evaluates task dependencies in-process, and two of those deps read
XCom: NotPreviouslySkippedDep reads skipmixin_key for every parent that inherits
from SkipMixin, and both it and TriggerRuleDep read past_depends_met when
wait_for_past_depends_before_skipping applies.

Both went through TaskInstance.xcom_pull -> XComModel.deserialize_value, which is
json.loads(value, cls=XComDecoder). XComDecoder's object_hook calls the Airflow
serialization module with full=True, so any nested dict carrying __classname__ is
imported and instantiated. The values these deps actually consume are primitives:
a mapping of lists of task ids, and a boolean. Nothing here needs an object
rebuilt, so the scheduler can read these values as plain JSON.

Add XComModel.deserialize_value_primitives, a plain json.loads with no
object_hook, and LazyXComPrimitivesSelectSequence alongside it. Thread full=True
through TaskInstance.xcom_pull and pass full=False at the four dep call sites.
All three of xcom_pull's return paths are covered -- the direct one, and both
lazy-sequence ones, which is the path a mapped task instance takes. The skip
decisions of SkipMixin tasks in the same mapped task group, which
NotPreviouslySkippedDep reads with one query per pass, are decoded the same way.

NotPreviouslySkippedDep also now checks that the skipmixin payload is a mapping
before testing membership in it. It reads whatever the parent task wrote, so a
scalar there previously raised TypeError inside dependency evaluation rather than
being ignored. Because the payload is now plain JSON, a set or tuple of task ids
arrives as its serde wrapper; its items are read from the wrapper without
constructing anything, and a decision whose task ids are not a list of strings is
ignored the same way.

Task code pulling another task's return value is unchanged and still gets the
original Python object; only the dependency-evaluation reads are narrowed.

Generated-by: Claude Opus 5
@potiuk
potiuk force-pushed the scheduler-xcom-dep-primitives-only branch from d75eb9a to ca8ef2d Compare October 15, 2026 22:52
@potiuk potiuk added the backport-to-v3-4-test Backport to v3-4-test label Oct 15, 2026
@potiuk potiuk added this to the Airflow 3.4.0 milestone Oct 15, 2026
@potiuk

potiuk commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

@ashb @kaxil Could you take a look at this when you have a moment? It's targeted at 3.4.0 and needs a review to make the cut on 2026-10-19. CI is green.

@vatsrahul1001 vatsrahul1001 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. All three xcom_pull return paths, including the lazy sequences mapped tasks use, read plain JSON for dependency evaluation, and a malformed skipmixin payload is now ignored instead of raising. Could use reviews from @ashb @kaxil before merging.

@potiuk
potiuk merged commit a7ac937 into apache:main Oct 19, 2026
112 checks passed
@potiuk
potiuk deleted the scheduler-xcom-dep-primitives-only branch October 19, 2026 14:56
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-4-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-4-test PR Link

potiuk added a commit that referenced this pull request Oct 19, 2026
… evaluation (#72718) (#75117)

* Read XCom without object reconstruction during dependency evaluation

The scheduler evaluates task dependencies in-process, and two of those deps read
XCom: NotPreviouslySkippedDep reads skipmixin_key for every parent that inherits
from SkipMixin, and both it and TriggerRuleDep read past_depends_met when
wait_for_past_depends_before_skipping applies.

Both went through TaskInstance.xcom_pull -> XComModel.deserialize_value, which is
json.loads(value, cls=XComDecoder). XComDecoder's object_hook calls the Airflow
serialization module with full=True, so any nested dict carrying __classname__ is
imported and instantiated. The values these deps actually consume are primitives:
a mapping of lists of task ids, and a boolean. Nothing here needs an object
rebuilt, so the scheduler can read these values as plain JSON.

Add XComModel.deserialize_value_primitives, a plain json.loads with no
object_hook, and LazyXComPrimitivesSelectSequence alongside it. Thread full=True
through TaskInstance.xcom_pull and pass full=False at the four dep call sites.
All three of xcom_pull's return paths are covered -- the direct one, and both
lazy-sequence ones, which is the path a mapped task instance takes. The skip
decisions of SkipMixin tasks in the same mapped task group, which
NotPreviouslySkippedDep reads with one query per pass, are decoded the same way.

NotPreviouslySkippedDep also now checks that the skipmixin payload is a mapping
before testing membership in it. It reads whatever the parent task wrote, so a
scalar there previously raised TypeError inside dependency evaluation rather than
being ignored. Because the payload is now plain JSON, a set or tuple of task ids
arrives as its serde wrapper; its items are read from the wrapper without
constructing anything, and a decision whose task ids are not a list of strings is
ignored the same way.

Task code pulling another task's return value is unchanged and still gets the
original Python object; only the dependency-evaluation reads are narrowed.

Generated-by: Claude Opus 5

* Treat only a literal True as past-depends-met during dependency evaluation

Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions

* Ignore skip decisions with a non-string classname
(cherry picked from commit a7ac937)


Generated-by: Claude Opus 5

Co-authored-by: Jarek Potiuk <[email protected]>
vatsrahul1001 pushed a commit that referenced this pull request Oct 20, 2026
… evaluation (#72718) (#75117)

* Read XCom without object reconstruction during dependency evaluation

The scheduler evaluates task dependencies in-process, and two of those deps read
XCom: NotPreviouslySkippedDep reads skipmixin_key for every parent that inherits
from SkipMixin, and both it and TriggerRuleDep read past_depends_met when
wait_for_past_depends_before_skipping applies.

Both went through TaskInstance.xcom_pull -> XComModel.deserialize_value, which is
json.loads(value, cls=XComDecoder). XComDecoder's object_hook calls the Airflow
serialization module with full=True, so any nested dict carrying __classname__ is
imported and instantiated. The values these deps actually consume are primitives:
a mapping of lists of task ids, and a boolean. Nothing here needs an object
rebuilt, so the scheduler can read these values as plain JSON.

Add XComModel.deserialize_value_primitives, a plain json.loads with no
object_hook, and LazyXComPrimitivesSelectSequence alongside it. Thread full=True
through TaskInstance.xcom_pull and pass full=False at the four dep call sites.
All three of xcom_pull's return paths are covered -- the direct one, and both
lazy-sequence ones, which is the path a mapped task instance takes. The skip
decisions of SkipMixin tasks in the same mapped task group, which
NotPreviouslySkippedDep reads with one query per pass, are decoded the same way.

NotPreviouslySkippedDep also now checks that the skipmixin payload is a mapping
before testing membership in it. It reads whatever the parent task wrote, so a
scalar there previously raised TypeError inside dependency evaluation rather than
being ignored. Because the payload is now plain JSON, a set or tuple of task ids
arrives as its serde wrapper; its items are read from the wrapper without
constructing anything, and a decision whose task ids are not a list of strings is
ignored the same way.

Task code pulling another task's return value is unchanged and still gets the
original Python object; only the dependency-evaluation reads are narrowed.

Generated-by: Claude Opus 5

* Treat only a literal True as past-depends-met during dependency evaluation

Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions

* Ignore skip decisions with a non-string classname
(cherry picked from commit a7ac937)


Generated-by: Claude Opus 5

Co-authored-by: Jarek Potiuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v3-4-test Backport to v3-4-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants