Skip to content

[v3-3-test] Fix new DAG versions from serializing a retry_policy object (#69243)#69315

Merged
vatsrahul1001 merged 1 commit into
v3-3-testfrom
backport-b56771c-v3-3-test
Jul 3, 2026
Merged

[v3-3-test] Fix new DAG versions from serializing a retry_policy object (#69243)#69315
vatsrahul1001 merged 1 commit into
v3-3-testfrom
backport-b56771c-v3-3-test

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor
  • Fix non-deterministic serialization of mapped task retry_policy

A mapped operator keeps retry_policy in partial_kwargs, but the mapped-operator
serializer has no serializer for a RetryPolicy, so it fell back to str(obj) --
embedding the object's per-process memory address. That made the serialized DAG
non-deterministic: dag_hash changed on every parse, defeating write_dag's
"unchanged" check and creating a new DagVersion on nearly every DAG-processor
re-serialization (even for idle, never-run DAGs), polluting version history and
bloating the metadata DB.

Non-mapped operators already avoid this by excluding the object and storing only
a has_retry_policy flag; this makes the mapped path do the same. Runtime is
unaffected -- the worker re-parses the DAG source for the live policy.

  • Also strip retry_policy from DAG default_args serialization

A RetryPolicy set via DAG default_args hit the same str(obj) fallback as the
mapped-operator case, embedding a memory address and producing a new DagVersion
on every parse. Route both the mapped partial_kwargs loop and the default_args
cleanup through a shared has-flag set (callbacks + retry_policy) so the object is
never serialized on either path.

  • Add negative test for mapped task without a retry_policy

Mapped operators resolve has_retry_policy through _get_partial_kwargs_or_operator_default
(falling back to SerializedBaseOperator's default) rather than the dataclass default, so the
false case warrants its own test alongside the existing non-mapped one.

  • Hoist retry_policy test imports and assert default_args has_retry_policy

Review follow-ups: move the retry_policy imports to module top (no collision, unlike
the SDK DAG import which stays local), shrink the has-flag branch comment to point at
_HAS_FLAG_FIELDS, and assert the positive side (has_retry_policy written, retry_policy
stripped) in the default_args test.
(cherry picked from commit b56771c)

Co-authored-by: Rahul Vats 43964496+vatsrahul1001@users.noreply.github.com

…ct (#69243)

* Fix non-deterministic serialization of mapped task retry_policy

A mapped operator keeps retry_policy in partial_kwargs, but the mapped-operator
serializer has no serializer for a RetryPolicy, so it fell back to str(obj) --
embedding the object's per-process memory address. That made the serialized DAG
non-deterministic: dag_hash changed on every parse, defeating write_dag's
"unchanged" check and creating a new DagVersion on nearly every DAG-processor
re-serialization (even for idle, never-run DAGs), polluting version history and
bloating the metadata DB.

Non-mapped operators already avoid this by excluding the object and storing only
a has_retry_policy flag; this makes the mapped path do the same. Runtime is
unaffected -- the worker re-parses the DAG source for the live policy.

* Also strip retry_policy from DAG default_args serialization

A RetryPolicy set via DAG default_args hit the same str(obj) fallback as the
mapped-operator case, embedding a memory address and producing a new DagVersion
on every parse. Route both the mapped partial_kwargs loop and the default_args
cleanup through a shared has-flag set (callbacks + retry_policy) so the object is
never serialized on either path.

* Add negative test for mapped task without a retry_policy

Mapped operators resolve has_retry_policy through _get_partial_kwargs_or_operator_default
(falling back to SerializedBaseOperator's default) rather than the dataclass default, so the
false case warrants its own test alongside the existing non-mapped one.

* Hoist retry_policy test imports and assert default_args has_retry_policy

Review follow-ups: move the retry_policy imports to module top (no collision, unlike
the SDK DAG import which stays local), shrink the has-flag branch comment to point at
_HAS_FLAG_FIELDS, and assert the positive side (has_retry_policy written, retry_policy
stripped) in the default_args test.
(cherry picked from commit b56771c)

Co-authored-by: Rahul Vats <43964496+vatsrahul1001@users.noreply.github.com>
@vatsrahul1001 vatsrahul1001 marked this pull request as ready for review July 3, 2026 09:07
@vatsrahul1001 vatsrahul1001 added this to the Airflow 3.3.0 milestone Jul 3, 2026
@vatsrahul1001 vatsrahul1001 merged commit 9b5619b into v3-3-test Jul 3, 2026
101 of 110 checks passed
@vatsrahul1001 vatsrahul1001 deleted the backport-b56771c-v3-3-test branch July 3, 2026 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant