villebro commented on code in PR #43463:
URL: https://github.com/apache/superset/pull/43463#discussion_r3845079352


##########
superset/common/query_context_processor.py:
##########
@@ -599,6 +607,21 @@ def get_cache_timeout(self) -> int:
         # Step 5: Global fallback.
         return current_app.config["CACHE_DEFAULT_TIMEOUT"]
 
+    def _apply_async_min_cache_ttl(self, timeout: int) -> int:
+        """Floor an async execution's result-cache TTL (no-op otherwise).
+
+        Only applies when this query context runs on the async path; a longer
+        timeout is kept as-is, and ``0`` (flask-caching "cache forever") is 
already
+        above any floor so it is left untouched. Synchronous requests are never
+        floored, even when GLOBAL_ASYNC_QUERIES is enabled.
+        """
+        if self._query_context.is_async_execution is not True:
+            return timeout
+        min_ttl: int = 
current_app.config.get("GLOBAL_ASYNC_QUERIES_MIN_CACHE_TTL", 0)
+        if 0 < timeout < min_ttl:
+            return min_ttl
+        return timeout

Review Comment:
   Good catch — valid and reachable. Native filter option queries can run on 
the async path (`FilterValue.tsx` passes `async_mode_override`), so flooring 
their dedicated `NATIVE_FILTER_OPTIONS_CACHE_TIMEOUT` to the async minimum 
would serve stale (and potentially RLS-constrained) filter values for the 
floor's duration.
   
   Fixed in 9a1b0d3cf5: `_resolve_cache_timeout` now reports whether the 
resolved timeout is floorable, and the native-filter-options branch returns 
`floorable=False` so `get_cache_timeout` skips the floor for it. Added 
`test_async_native_filter_options_query_is_not_floored` (30s stays 30s on the 
async path). The general result-cache timeouts (steps 3–5) and explicit 
`custom_cache_timeout` still floor, since those results genuinely need to 
survive the async cache→read-back round trip.



-- 
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]

Reply via email to