Skip to content

fix: intermittent retrieval error under high concurrency #33895

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
bugfix: intermittent retrieval error under high concurrency
  • Loading branch information
KaijieShao committed Jun 24, 2025
commit 0594e4c104c9f0a940cc23f8960e9a07eb74e352
30 changes: 30 additions & 0 deletions superset/datasets/api.py
Original file line number Diff line number Diff line change
@@ -17,18 +17,22 @@
# pylint: disable=too-many-lines
from __future__ import annotations

import copy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is not being used anywhere. Should be removed

Suggested change
import copy

import logging
from datetime import datetime
from io import BytesIO
from typing import Any, Callable, Dict
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extraneous import

Suggested change
from typing import Any, Callable, Dict

from typing import Any, Callable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dict type should be imported here

Suggested change
from typing import Any, Callable
from typing import Any, Callable, Dict

from zipfile import is_zipfile, ZipFile

from flask import request, Response, send_file
from flask_appbuilder.api import expose, protect, rison, safe
from flask_appbuilder.api.schemas import get_item_schema
from flask_appbuilder.models.filters import Filters
from flask_appbuilder.const import (
API_RESULT_RES_KEY,
API_SELECT_COLUMNS_RIS_KEY,
API_FILTERS_RIS_KEY,
)
from flask_appbuilder.models.sqla.interface import SQLAInterface
from flask_babel import ngettext
@@ -299,6 +303,32 @@
list_outer_default_load = True
show_outer_default_load = True

def _handle_filters_args(self, rison_args: Dict[str, Any]) -> Filters:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the new function here, is it being called anywhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's likely an override for existing FAB method.

"""
Handle filters arguments passed to the API endpoint.
Parses and applies filtering criteria provided as Rison-encoded arguments
to construct a Filters instance. This method ensures that each request
uses an isolated Filters instance to avoid shared state issues
in concurrent or asynchronous environments.
Example input:
rison_args = {
"filters": [
{"col": "table_name", "opr": "eq", "value": "some_table"}
]
}
:param rison_args: A dictionary of arguments parsed from the API request'sAdd commentMore actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indent this sentence to be on par with remaining comments

Suggested change
:param rison_args: A dictionary of arguments parsed from the API request'sAdd commentMore actions
:param rison_args: A dictionary of arguments parsed from the API request'sAdd commentMore actions

Rison-encoded `q` parameter.
:returns: A Filters instance containing the applied filters.
"""
filters = self.datamodel.get_filters(

Check warning on line 325 in superset/datasets/api.py

Codecov / codecov/patch

superset/datasets/api.py#L325

Added line #L325 was not covered by tests
search_columns=self.search_columns, search_filters=self.search_filters
)
# self._filters.clear_filters()
filters.rest_add_filters(rison_args.get(API_FILTERS_RIS_KEY, []))
return filters.get_joined_filters(self._base_filters)

Check warning on line 330 in superset/datasets/api.py

Codecov / codecov/patch

superset/datasets/api.py#L329-L330

Added lines #L329 - L330 were not covered by tests

@expose("/", methods=("POST",))
@protect()
@safe