Skip to content

Run triggerer asset listeners after the event is committed - #77024

Open
kacpermuda wants to merge 2 commits into
apache:mainfrom
kacpermuda:run-trigger-asset-listeners-after-commit
Open

kacpermuda wants to merge 2 commits into
apache:mainfrom
kacpermuda:run-trigger-asset-listeners-after-commit

Conversation

@kacpermuda

@kacpermuda kacpermuda commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Asset listeners fired by a trigger (on_asset_changed, on_asset_event_emitted) ran inside the triggerer's transaction, before Dag runs were queued and before commit. The task path already commits first (execution_api/routes/task_instances.py); Trigger.submit_event now does the same.

How this can take down the triggerer: the run loop does not catch errors from handle_events, so a failed commit stops the process. Say a custom listener posts to a webhook that hangs, for longer than Postgres idle_in_transaction_session_timeout. Postgres closes the connection, the commit raises, and the triggerer exits. With a shared-stream watcher the broker redelivers the event, the listener blocks again, and the triggerer crash-loops, so none of its triggers make progress. Even without a crash, listeners have already reported an asset event that was rolled back.

The upcoming OpenLineage listener (#76773) queues its sends on a background thread, so it does not block, but it would still report rolled-back events as lineage.

related: #76750


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5.5)

Generated-by: Claude Code (Opus 5.5) following the guidelines

🤖 Generated with Claude Code

@kacpermuda
kacpermuda marked this pull request as ready for review November 13, 2026 14:05

@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.

Could you remove the Co-Authored-By: Claude ... trailer? Our AGENTS.md says agents should not be listed as commit co-authors.

@kacpermuda
kacpermuda force-pushed the run-trigger-asset-listeners-after-commit branch from 6c4cddb to b7b3732 Compare November 20, 2026 11:15
@kacpermuda

Copy link
Copy Markdown
Collaborator Author

Done, good to merge, thanks !

@hussein-awala hussein-awala 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.

LGTM, just added a nit comment

@kacpermuda
kacpermuda force-pushed the run-trigger-asset-listeners-after-commit branch from b7b3732 to b046033 Compare November 20, 2026 12:35
@kacpermuda

Copy link
Copy Markdown
Collaborator Author

Can we backport this to 3.4.1 ?

@hussein-awala

Copy link
Copy Markdown
Member

Can we backport this to 3.4.1 ?

I believe we can since it's a misc, but let's check with @vatsrahul1001 first

@Lee-W Lee-W added the backport-to-v3-4-test Backport to v3-4-test label Nov 20, 2026
@Lee-W

Lee-W commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

This looks like a bug fix to me. But I'll let @vatsrahul1001 decide. added the label and milestone. we can remove them if we don't want ot

@Lee-W Lee-W added backport-to-v3-4-test Backport to v3-4-test and removed backport-to-v3-4-test Backport to v3-4-test labels Nov 20, 2026
@Lee-W Lee-W added this to the Airflow 3.4.1 milestone Nov 20, 2026
@hussein-awala

Copy link
Copy Markdown
Member

This looks like a bug fix to me

The current implementation doesn't fix any bug, it just prepare for the upcoming OpenLineage listener.

@kacpermuda

Copy link
Copy Markdown
Collaborator Author

The current implementation doesn't fix any bug

I think it's a bug, just not currently exposed by any listener that lives in airflow repo. If somebody runs their own listener that meets the criteria above, it can still kill the triggerer. So treating this as a bug fix is correct imho

Asset listeners ran inside the triggerer's transaction, before Dag runs were
queued and before commit. A slow listener kept the transaction open, and a
failed commit left listeners reporting an asset event that never existed.
@kacpermuda
kacpermuda force-pushed the run-trigger-asset-listeners-after-commit branch from b046033 to 7eca023 Compare November 23, 2026 12:43

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants