villebro commented on code in PR #43463:
URL: https://github.com/apache/superset/pull/43463#discussion_r3845085939
##########
superset/tasks/async_queries.py:
##########
@@ -122,6 +122,9 @@ def execute_chart_query(
"""
with override_user(_resolve_user(user_id, guest_token), force=False):
query_context = load_serialized_query(serialized_query)
+ # Floor the result-cache TTL: async caches the result for a follow-up
+ # request to read back (see get_cache_timeout).
+ query_context.is_async_execution = True
Review Comment:
The mechanism is correct — on a cache hit `get_df_payload_result` skips
`set_query_result`, so an entry another request populated with a short TTL
keeps that TTL — but in practice this is low-severity and self-healing, so I've
left it as-is:
- **Async vs. async can't race.** Each `QueryObject` runs as a SHARED GTF
task keyed by `query_cache_key`, so concurrent async requests for the same key
dedup to one task. There is no second async writer.
- **The only race is async-task vs. a concurrent *sync* request** (sync
never floors). For it to actually cause a re-fetch miss, the sync-written TTL
must expire in the window between the async task observing the hit and the
client re-issuing — roughly one poll interval (~0.5–1s). Only a pathologically
sub-second `DATA_CACHE` TTL would bite.
- **It self-heals.** On a re-request miss the async flow just schedules the
query again and succeeds on the next round; it degrades to one extra round
trip, not a hang.
Re-setting the TTL on every async cache hit would add a cache write to the
hot path (flask-caching has no cheap "touch"/EXPIRE through
`QueryCacheManager`) to cover a self-correcting sub-second edge case, which
isn't a good trade. Happy to revisit if you'd prefer the guard.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]