Skip to content

Fix race when concurrent tasks first emit the same asset through an alias - #76827

Merged
Lee-W merged 3 commits into
apache:mainfrom
yakovlef:fix-asset-alias-race
Nov 20, 2026
Merged

Lee-W merged 3 commits into
apache:mainfrom
yakovlef:fix-asset-alias-race

Conversation

@yakovlef

@yakovlef yakovlef commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

closes: #76738

when two TIs report success at the same time and emit the same new asset through an alias, the loser got an IntegrityError and was marked FAILED without retry

  • dynamic AssetModel creation in register_asset_changes_in_db now inserts in a savepoint, on IntegrityError it reuses the row the other writer created
  • _add_asset_alias_association links aliases in a savepoint, on conflict reloads asset_model.aliases and adds only the missing ones (same pattern as _get_or_create_apdr)
  • 2 tests that reproduce both cases from the issue deterministically (second session commits between our read and our insert), both failed on postgres before the fix

the catch-all in ti_update_state that turns any error into a non-retryable FAILED is left as is, can do that separately if wanted


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

I investigated the issue and reproduced it, used claude code as a coding assistant for the fix and tests, reviewed and tested everything locally (breeze, postgres/mysql/sqlite)

@boring-cyborg

boring-cyborg Bot commented Nov 10, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@yakovlef
yakovlef force-pushed the fix-asset-alias-race branch from eb6ce34 to 9ed64a7 Compare November 12, 2026 10:34

@uranusjr uranusjr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still a couple of carry-overs from before this bug, but this PR by itself is fine.

@Lee-W Lee-W left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

a few nits

@yakovlef

Copy link
Copy Markdown
Contributor Author

thanks, applied all three

@Lee-W
Lee-W enabled auto-merge (squash) November 20, 2026 09:11
@Lee-W
Lee-W merged commit 75026dc into apache:main Nov 20, 2026
81 checks passed
@boring-cyborg

boring-cyborg Bot commented Nov 20, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

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.

Concurrent first AssetAlias emission for the same asset fails the losing task instances with IntegrityError (no retry)

3 participants