You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Snowflake operators in deferred mode generate JWT tokens on every poll instead of reusing them #59385
When using SnowflakeSqlApiOperator in deferred mode (deferrable=True), the operator generates a new JWT token on every polling attempt instead of reusing the existing token. This causes:
Performance overhead: Unnecessary token generation on every poll (which can happen every few seconds)
Log pollution: INFO level logs are generated on every poll, flooding the task logs and making it difficult to track actual task progress
Current Behavior
In deferred mode, when the operator polls for query status, it generates a new JWT token for each poll attempt, even though the previous token is still valid. This results in:
Excessive token generation operations
Cluttered logs with repeated JWT generation messages
What you think should happen instead
The JWT token should be reused across polling attempts until it expires or needs renewal. Token generation should only occur when:
No token exists yet
The token has expired
The token renewal time has been reached
How to reproduce
Create a SnowflakeSqlApiOperator with deferrable=True
Execute a long-running query that requires multiple polls
Observe the logs - you'll see JWT token generation logs on every poll
Check the task logs - they will be cluttered with JWT generation messages
Anything else
Impact
Performance: Unnecessary cryptographic operations on every poll
Log pollution: INFO level logs on every poll make it difficult to track actual task progress
Resource waste: CPU cycles spent on token generation that could be avoided
Additional Context
The token caching mechanism exists but is not being utilized effectively in deferred mode.
"""Wait for the query the snowflake query to complete."""SnowflakeSqlApiHook(
self.snowflake_conn_id,
self.token_life_time,
self.token_renewal_delta,
)
Activity
jroachgolf84 commentedon Dec 15, 2025
Looks like this snippet of code... Doesn't actually seem like that hook is being used once it's created. But I could be missing something...
https://github.com/apache/airflow/blob/e1adf0b1eba8fb5e00046cf49f15da3de59ff705/providers/snowflake/src/airflow/providers/snowflake/triggers/snowflake_trigger.py#L70C1-L75C10
jroachgolf84 commentedon Dec 15, 2025
jroachgolf84 commentedon Dec 15, 2025
I've created a PR for this: #59470