ferruzzi commented on code in PR #68367:
URL: https://github.com/apache/airflow/pull/68367#discussion_r3406504881
##########
airflow-core/src/airflow/assets/manager.py:
##########
@@ -397,7 +397,12 @@ def register_asset_change(
)
)
- stats.incr("asset.updates")
+ team_name = None
+ if task_instance and conf.getboolean("core", "multi_team"):
+ from airflow.models.dag import DagModel
+
+ team_name = DagModel.get_team_name(task_instance.dag_id,
session=session)
Review Comment:
> The cache on `DagModel.get_team_name(...)` covers us from hammering the DB
with this metric right?
The scheduler's `_dag_id_to_team_name` cache doesn't apply here because the
classmethd `register_asset_change` doesn't go through the scheduler's lookup.
But the TTL cache on `DagModel.get_team_name()` itself does apply and provides
a 30-second (configurable) buffer, so repeated calls for the same `dag_id`
won't hammer the DB.
I'm not sure which cache you are thinking so I may not be answering the
question you are asking, but while checking to verify the answer I noticed I'm
calling `DagModel.get_team_name()` twice. I will remove the call on L413 and
reuse the existing value from L404, which may or may not be what you are
concerned about.
--
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]