Skip to content
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

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion superset/charts/data/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from typing import Any, Dict, Optional, TYPE_CHECKING, Union

import simplejson
from flask import current_app, make_response, request, Response
from flask import current_app, g, make_response, request, Response
from flask_appbuilder.api import expose, protect
from flask_babel import gettext as _
from marshmallow import ValidationError
Expand Down Expand Up @@ -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)
kekwan marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

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?

query_context = self._create_query_context_from_form(cached_data)
command = ChartDataCommand(query_context)
command.validate()
Expand Down
4 changes: 3 additions & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,9 @@ def explore_json_data(self, cache_key: str) -> FlaskResponse:

form_data = cached.get("form_data")
response_type = cached.get("response_type")

# Set form_data in Flask Global as it is used as a fallback
# for async queries with jinja context
setattr(g, "form_data", form_data)
datasource_id, datasource_type = get_datasource_info(None, None, form_data)

viz_obj = get_viz(
Expand Down