-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: url_params cache miss with global async query #23641
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks for fixing this long standing bug!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kekwan I was too quick to approve - there's a missing import, and some linting errors. Let's see if fixing those clears up CI
f6b31eb
to
fb60d4b
Compare
b4f5e4d
to
3059f23
Compare
cbe6899
to
6dbbad2
Compare
Codecov Report
@@ Coverage Diff @@
## master #23641 +/- ##
=======================================
Coverage 68.08% 68.08%
=======================================
Files 1920 1920
Lines 73990 73992 +2
Branches 8091 8091
=======================================
+ Hits 50374 50376 +2
Misses 21547 21547
Partials 2069 2069
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
thanks @villebro, fixed all the linting issues. |
@kekwan I restarted the Presto test suite - if it keeps coming back red we should consider disabling it in the Presto test suite (there's quite a few others that have had to be disabled, too) |
@villebro seems like its been failing consistently on latest builds on master. let me know if you want me to disable it as part of this PR. |
…orm_data import flask g fix linting fix linting 2
6dbbad2
to
6e0ff2b
Compare
thanks @villebro rebased |
Perfect, thanks for all the work and patience here @kekwan ! ❤️ |
@@ -299,6 +299,9 @@ def data_from_cache(self, cache_key: str) -> Response: | |||
""" | |||
try: | |||
cached_data = self._load_query_context_form_from_cache(cache_key) | |||
# Set form_data in Flask Global as it is used as a fallback | |||
# for async queries with jinja context | |||
setattr(g, "form_data", cached_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to do this instead of g.form_data = cached_data
?
SUMMARY
Fixes initial cache miss when global async queries are used.
Currently, whenever a Jinja context is used in a query such as
url_params
with async queries enabled, a call to get_form_data is made.form_data
which has the url_params is used to generate extra cache keys. Right now, form_data is empty as there is no request context in async queries. This means that we are always encountering a cache miss on the first query.Since async queries won't have request context, we need to fallback to setting Flask global. https://github.com/apache/superset/blob/master/superset/views/utils.py#L182
BEFORE/AFTER SCREENSHOTS OR
BEFORE
Screen.Recording.2023-04-10.at.4.45.16.PM.mov
AFTER
Screen.Recording.2023-04-10.at.4.19.37.PM.mov
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION