Skip to content

perf(dashboard): look up the dashboard once per filter_state read - #46314

Merged
rusackas merged 1 commit into
apache:masterfrom
uhyunpark:perf/filter-state-single-dashboard-lookup
Nov 21, 2026
Merged

rusackas merged 1 commit into
apache:masterfrom
uhyunpark:perf/filter-state-single-dashboard-lookup

Conversation

@uhyunpark

Copy link
Copy Markdown
Contributor

SUMMARY

GET /api/v1/dashboard/<id>/filter_state/<key> looks the dashboard up twice. check_access loads it to check access, then get_filter_names (added in #44043) loads it again to read the filter names. Each lookup runs the dashboard access filter and raise_for_access. With the default metastore-backed filter state cache, refreshing the entry between the two lookups commits and expires the session, so the second lookup also reloads the user with their roles and groups.

This keeps the metadata from the first lookup: check_access returns the dashboard it loaded, and GetFilterStateCommand holds its json_metadata for get_filter_names. The metadata is read before the refresh, because the commit expires the loaded dashboard.

The frontend calls this endpoint when a dashboard opens with a native_filters_key in the URL.

Metadata statements per request, counted with before_cursor_execute through the Flask test client on a SQLite metadata database with the default config:

user master this branch
Admin 15 12
Gamma with access to the dashboard's datasets 58 34

The counts are the same for a dashboard of 5 charts and one of 25.

Access is still checked once per request, before the stored value is read. The lookup removed here was a second check of the same dashboard for the same user in the same request. get_filter_names still looks the dashboard up itself when it is called without a prior get, and the create, update and delete commands ignore the new return value of check_access.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

pytest tests/unit_tests/dashboards/filter_state_api_test.py

The new test_get_looks_up_the_dashboard_once checks the response and that the dashboard is looked up once. On master it fails with Expected 'get_by_id_or_slug' to be called once. Called 2 times.

To check by hand: open a dashboard with native filters, apply a filter and reload the page. The filter values are restored, and the filter_state/<key> response still carries value and names.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

GET /api/v1/dashboard/<id>/filter_state/<key> loaded and access-checked
the dashboard twice: once in check_access and again in get_filter_names.
Refreshing the entry in between commits and expires the session, so the
second lookup also reloaded the user and their roles.

check_access returns the dashboard it loaded, and the command keeps its
metadata for get_filter_names.
@codeant-ai-for-open-source

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 4608692e44cf

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.43%. Comparing base (32b4d6b) to head (4608692).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
superset/commands/dashboard/filter_state/get.py 62.50% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #46314      +/-   ##
==========================================
- Coverage   85.43%   85.43%   -0.01%     
==========================================
  Files        3100     3100              
  Lines      213566   213570       +4     
  Branches    50411    50412       +1     
==========================================
+ Hits       182464   182467       +3     
- Misses      27675    27676       +1     
  Partials     3427     3427              
Flag Coverage Δ
hive 34.03% <27.27%> (-0.01%) ⬇️
mysql 51.73% <72.72%> (-0.01%) ⬇️
postgres 51.76% <72.72%> (-0.01%) ⬇️
presto 35.73% <27.27%> (-0.01%) ⬇️
python 88.19% <72.72%> (-0.01%) ⬇️
sqlite 51.44% <72.72%> (-0.01%) ⬇️
unit 83.41% <72.72%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @uhyunpark, nice catch on the doubled lookup, and good call reading the metadata before the refresh commit expires it. LGTM!

@rusackas
rusackas merged commit 1a08646 into apache:master Nov 21, 2026
77 checks passed
jprinet added a commit to jprinet/superset that referenced this pull request Nov 23, 2026
* origin/master: (393 commits)
  fix(a11y): name the semantic view description input (apache#46458)
  docs(semantic): explain datasource list modification eligibility (apache#46462)
  docs(semantic-layer): document NULL-preserving exclusion filters (apache#46447)
  fix(uploads): skip folder and system entries in columnar ZIP uploads (apache#45617)
  fix(i18n-es): promote 47 of the zero-context backfill entries (apache#45847)
  fix(mcp): return structured ChartError on SQLAlchemyError in get_chart_sql (apache#44351)
  fix(datasets): follow semantic view modification permissions (apache#46448)
  fix(docker): account for container memory limits in frontend-mem-nag.sh (apache#46373)
  fix(reports): carry the report's native filters in the email and Slack link (apache#46062)
  fix(explore): apply the dataset timezone to grained temporal filter values (apache#46175)
  fix(i18n): enforce the do-not-translate registry across the catalogs (apache#45974)
  chore(logging): log unparseable virtual dataset SQL at debug in the RLS lookup (apache#46139)
  fix(i18n): split parameter-suggestion plural into two messages (apache#46049)
  test(partition-mapping): cover Hive/Impala mirrored SQL, cache outage and migration (apache#46319)
  perf(dashboard): look up the dashboard once per filter_state read (apache#46314)
  fix(i18n): load the dayjs locale for every language with a catalog (apache#45982)
  test(semantic-layer): make date export parametrization deterministic (apache#46449)
  fix(oauth2): idempotent OAuth2 completion and resilient listener (apache#40292)
  fix(explore): prevent full table scan when SQL expression is used as x-axis (apache#41339)
  feat(mcp): radar chart type plugin (apache#43571)
  ...

# Conflicts:
#	.github/workflows/docker.yml
#	.github/workflows/superset-frontend.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants