dstandish opened a new pull request, #68687: URL: https://github.com/apache/airflow/pull/68687
## Summary `TaskInstance.register_asset_changes_in_db` runs on every task-success state transition (from the execution API `PATCH .../state` handler). For a task that declares **no** outlet assets and emits **no** outlet events — the common case — the method still executed its full body, including an `AssetModel` SELECT whose `IN (...)` clauses are all empty, before ultimately doing nothing. This adds an early return when both `task_outlets` and `outlet_events` are empty, eliminating that database round-trip. It sits on the task-completion path, which gates how quickly the next task can be scheduled. ## Detail - `airflow-core/src/airflow/models/taskinstance.py`: early-return guard at the top of `register_asset_changes_in_db`. - All downstream work (`payloads_by_asset`, the `AssetModel` lookup, the per-key `_register` calls, and the alias path) derives from `task_outlets` / `outlet_events`, so when both are empty the method is already a no-op — this just makes that explicit and cheap. ## Tests Added `test_register_asset_changes_in_db_no_outlets_is_a_noop`, which asserts (via `assert_queries_count(0)`) that no queries are issued for a task with no outlets. Existing asset-registration / partition tests continue to pass. > [!NOTE] > Opened as a draft for review. No user-facing behavior change — purely an optimization on the task-completion path. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
