Cache dag access and teams check to be reused in grid ti_summary API calls#61623
Cache dag access and teams check to be reused in grid ti_summary API calls#61623tirkarthi wants to merge 1 commit intoapache:mainfrom
Conversation
requires_access_dag is used in the ti_summary endpoint. When this method returns a result then this can be cached and reused for other API calls since access to a dag doesn't change based on taskinstance.
|
As per my understanding there are only 5 connections in the pool by default and with concurrent requests and db calls being made synchronously in requires_access_dag and in the endpoint other requests might need to wait based on max_overflow. |
There was a problem hiding this comment.
I think we should think about the cache invalidation cycle too.
For instance if I update the permissions of the user the is_authorized_dag cache isn't invalidated, and therefore the user won't have access until cache expires (I don't know when in the current implementation)
Also different workers can have different version of the cache in these specific case, one worker might grant access, while the other can block the access, I think this is a problem.
|
Thanks @pierrejeambrun . I updated the signature for the caching key and still see failures about the permission which I assume is about caching invalidation. The primary intention of the PR was around recurring checks for dag access around the same time within 1-2 seconds the grid loads. I will see if I can bring up an approach or to have a shorter ttl like 1-2 seconds within the grid loading cycle. |
requires_access_dag is used in the ti_summary endpoint. When this method returns a result then this can be cached and reused for other API calls since access to a dag doesn't change based on taskinstance. On a similar note for dags that don't have many changes the serialized dag entry also remains the same.
This PR adds caching to airflow-core which is independent from
fabprovider. Hence the fab related ttl cannot be always used and this might need a new config if the approach is accepted.command with 10 concurrent requests since the grid loads 10 dagruns by default.
Main branch
cache only
is_authorized_dagin fab auth manager used inrequires_access_dagcheckcache
get_team_nameandis_authorized_dagin fab auth manager used inrequires_access_dagcheckcache
get_team_nameandis_authorized_dagin fab auth manager used inrequires_access_dagcheck and_get_serdag.related: #61485
Was generative AI tooling used to co-author this PR?
No