Repository navigation
Fix wrong watcher name for assets sharing an identical trigger - #76982
Conversation
bingqin2
left a comment
There was a problem hiding this comment.
Tested on main at da7dab3 on macOS (SQLite). collection.py, models/asset.py and test_collection.py haven't changed between that commit and 7dfc579.
I synced one Dag scheduled on two assets whose watchers use an identical FileDeleteTrigger:
- On main both
asset_watcherrows are namedb_watcher. With this change they area_watcherandb_watcher, and there is still oneTriggerrow. - The new test fails on main and passes with this change.
test_collection.pypasses (99 passed, 2 skipped), and ruff and mypy pass on the changed files.
Not blocking: the name is written only when the reference is created, so two cases keep the old name on the next sync, on main and with this change:
| Case | Stored name after the next sync |
|---|---|
Rows that main already stored as b_watcher for both assets |
still b_watcher for both |
| A watcher renamed in the Dag file, with the same trigger | still the old name |
Pausing and unpausing the Dag recreates the references with the right names. I also tried updating the name of the references that already exist, before the "no diff" shortcut. Both cases then store the right name, and test_collection.py still passes. Since #76750 exposes this name to listeners, it may be worth a follow-up.
The change I tried
# Keep the names of references that already exist in step with the Dag definition.
for watcher in asset_model.watchers:
if watcher.trigger is None:
continue
current_name = watcher_names[name_uri].get(
BaseEventTrigger.hash(watcher.trigger.classpath, watcher.trigger.kwargs)
)
if current_name is not None and watcher.name != current_name:
watcher.name = current_name48b0bfc to
194c12b
Compare
|
Thanks, addressed this in the last commit |
Lee-W
left a comment
There was a problem hiding this comment.
Could you remove the Co-Authored-By: Claude ... trailer in each commit
194c12b to
a7764bb
Compare
|
Done, good to merge, thanks ! |
|
Can we backport this to 3.4.1 ? |
Backport successfully created: v3-4-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
…igger (#76982) (cherry picked from commit 60d6099) Co-authored-by: Kacper Muda <[email protected]>
When watchers on different assets used an identical trigger (same class and kwargs),
add_asset_trigger_referencesstored the watcher name of the last processed asset for all of them. Watcher names are now tracked per asset.Both watchers correctly share one
Triggerrow, but the trigger info (includingwatcher_name) was collected into one dict for all assets, keyed only by trigger hash. The second asset overwrote the first asset's entry, soordersgot a watcher namedcustomers_watcher. The trigger still fired for both assets, so only the stored name was wrong.Watcher names were also only written when a reference was created, so a wrong name already stored by this bug, or a watcher renamed in the Dag file with the same trigger, stayed wrong until the Dag was paused and unpaused. Existing watcher names are now updated on every sync.
related: #76750 (exposes the watcher name to listeners)
related: #76773 (its OpenLineage e2e test with two assets sharing a trigger got the wrong
watcherName)Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5.5) following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.🤖 Generated with Claude Code