Repository navigation
fix(dashboard): don't hang forever when saved native filter state request stalls - #45928
Conversation
…uest stalls Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #45928 +/- ##
==========================================
+ Coverage 84.76% 84.78% +0.01%
==========================================
Files 3072 3074 +2
Lines 206140 206303 +163
Branches 48549 48593 +44
==========================================
+ Hits 174741 174907 +166
+ Misses 28100 28099 -1
+ Partials 3299 3297 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ip error log on abort Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…er state can't load Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…s.pot Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
| const nativeFiltersCacheKey = getUrlParam(URL_PARAMS.nativeFiltersKey); | ||
| const dataMask = JSON.stringify(dataMaskSelected); | ||
|
|
||
| const forceNewKey = consumeNeedsNewKey(); |
There was a problem hiding this comment.
Suggestion: After this flag is consumed, another debounced publish can run before key creation finishes, see the original URL key, and overwrite the shared state.
Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Race condition
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx
**Line:** 136:136
**Comment:**
*Race Condition: After this flag is consumed, another debounced publish can run before key creation finishes, see the original URL key, and overwrite the shared state.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| }) | ||
| endpoint, | ||
| signal, | ||
| fetchRetryOptions: { retries: 0 }, |
There was a problem hiding this comment.
Suggestion: getPermalinkValue now uses this no-retry request, so a transient 502 is swallowed after one attempt and chat-applied filters are silently skipped.
Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Api mismatch
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/dashboard/components/nativeFilters/FilterBar/keyValue.tsx
**Line:** 75:75
**Comment:**
*Api Mismatch: `getPermalinkValue` now uses this no-retry request, so a transient 502 is swallowed after one attempt and chat-applied filters are silently skipped.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 772a1ef.
getPermalinkValue now uses the regular SupersetClient.get call rather than getOnce, which sets fetchRetryOptions: { retries: 0 }.
If that's not right, unresolve this thread and CodeAnt will leave it open.
There was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of ed38d26.
getPermalinkValue now uses the regular SupersetClient.get call rather than getOnce, which sets fetchRetryOptions: { retries: 0 }.
If that's not right, unresolve this thread and CodeAnt will leave it open.
There was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of ea87299.
getPermalinkValue now uses the regular SupersetClient.get request, while the no-retry getOnce helper is used by fetchPermalinkValue.
If that's not right, unresolve this thread and CodeAnt will leave it open.
| source, | ||
| controller.signal, | ||
| ); | ||
| if (controller.signal.aborted) return; |
There was a problem hiding this comment.
Suggestion: If dashboard navigation aborts a pending retry, this return skips resetting isRetryingSharedState; a later failure banner can leave Try again permanently loading.
Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Logic error
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/dashboard/containers/DashboardPage.tsx
**Line:** 456:456
**Comment:**
*Logic Error: If dashboard navigation aborts a pending retry, this return skips resetting `isRetryingSharedState`; a later failure banner can leave Try again permanently loading.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| const mask = | ||
| source.kind === 'permalink' | ||
| ? (result.value as DashboardPermalinkValue)?.state?.dataMask | ||
| : (result.value as Record<string, DataMask> | null); |
There was a problem hiding this comment.
Suggestion: retrySharedState applies only state.dataMask, then clears the warning; permalink activeTabs, chartStates, and anchor remain unapplied after a successful retry.
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Incomplete implementation
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset-frontend/src/dashboard/containers/DashboardPage.tsx
**Line:** 462:465
**Comment:**
*Incomplete Implementation: `retrySharedState` applies only `state.dataMask`, then clears the warning; permalink `activeTabs`, `chartStates`, and `anchor` remain unapplied after a successful retry.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 772a1ef.
On retry success, the code passes toSharedState(source, result.value) to hydrateWithStateRef, applying the full shared state before clearing the notice.
If that's not right, unresolve this thread and CodeAnt will leave it open.
There was a problem hiding this comment.
✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of ed38d26.
On retry success, the code passes toSharedState(source, result.value) to hydrateWithStateRef, applying the full shared state before clearing the notice.
If that's not right, unresolve this thread and CodeAnt will leave it open.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…essage Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
fitzee
left a comment
There was a problem hiding this comment.
Adversarial review of ed38d266. CI is green and the core fix (a bounded load instead of an infinite spinner, and an explicit banner instead of silent defaults) is a clear improvement over master. I traced the fallback state against the share menu, the realtime chat-filter path and the backend filter-state update command. Findings, most important first:
1. Copy permalink after a fallback shares the default view, which contradicts the description.
ShareMenuItems.generateUrl builds the permalink from Redux dataMask, which holds the defaults at that point. getDashboardUrlParams also drops native_filters_key, because it is in RESERVED_DASHBOARD_URL_PARAMS.
So the recipient opens a valid permalink that contains the defaults and shows no banner. That is exactly the silent mismatch this PR is meant to prevent. It isn't a regression, since master hangs instead, but the description says Copy permalink still uses the shared state.
Either fix it (for example, warn or disable in Share while the hold is active, or carry the original key through), or drop that claim and list it under NOT COVERED.
2. Try again can overwrite filters applied from chat.
useDashboardFilterSync dispatches updateDataMask directly and never calls releaseFilterKeyPublish(). After a fallback, a "Filters applied from chat" update leaves the banner up. Clicking Try again then re-hydrates the saved state over those filters.
The same thing happens with cross-filters, which you already list under NOT COVERED. Both come from the same root cause: the release is tied to handleApply rather than to user-originated dataMask changes in general. See the inline comment.
3. The 3 s timeout aborts requests that are slow but healthy.
Each attempt aborts the in-flight request at 3 s and the retry starts again from zero. If the backend consistently takes about 4 s (for example the default SupersetMetastoreCache filter-state backend on a busy metadata DB), both attempts fail and the viewer gets defaults plus the banner. Master would have loaded the right state in that case.
The retry helps when a connection is dropped, but not when the server is slow. See the inline comment.
4. isRetryingSharedState can get stuck on true. (I agree with the CodeAnt thread on L489.)
DashboardRoute doesn't key DashboardPage by idOrSlug, so SPA navigation between dashboards reuses the same instance. The effect cleanup aborts retryController, and retrySharedState then returns before it resets the flag. If the next dashboard also falls back, Try again shows as a button that never stops loading.
Resetting the flag in a finally block, or at the start of the load effect, fixes it. The cancelled early return on L366 leaves isLoadingSharedState stale in the same way, though there it's only cosmetic.
5. Minor / FYI
- The race CodeAnt raised on
FilterBar/index.tsx:136is mostly contained on the server.UpdateFilterStateCommandreturns 403 when the owner is different, and otherwise writes to the contextual key for the session and tab. The original key can only be overwritten if the same tab created it, which is how master already behaves. - The "expired" banner is effectively unreachable for
/superset/dashboard/p/<key>/links.Superset.dashboard_permalinkresolves the key on the server and returns 404 JSON before the SPA loads, so the banner only appears for a direct?permalink_key=. That's worth reflecting in manual test step 4. - A stored value that fails
JSON.parseinfetchFilterValueis classed asfailedand retried, so Try again can never succeed for it. Mapping it toexpiredwould avoid a pointless retry offer. getOncereplaces the client's default 503 retries (3 retries, 1 s apart) with 2 attempts in total. That's acceptable, but it is a behaviour change worth knowing about.
Verdict: the fix for the hang is solid and well tested; cancellation, a dashboard change mid-fetch and Try again on a permalink are all covered. LGTM once #1 is resolved (fixed, or the description corrected) and #4 is fixed. #2 and #3 are worth doing, but could reasonably be follow-ups.
| setSharedStateNotice(result.status === 'expired' ? 'expired' : 'failed'); | ||
| return; | ||
| } | ||
| hydrateWithStateRef.current(toSharedState(source, result.value)); |
There was a problem hiding this comment.
This re-hydrates over anything that changed the dataMask without going through handleApply, which means filters applied from chat via useDashboardFilterSync and cross-filters. The banner stays up after either of those, so Try again is still offered.
One option: release the hold (and hide the banner) on any user-originated dataMask change after the initial hydrate, not only on Apply. That would also close the cross-filter gap listed under NOT COVERED.
There was a problem hiding this comment.
Addressed in ea87299. The hold is now released on every user-originated filter change, not only Apply: chart-click cross-filters (in chartAction's setDataMask, filter changes only, so own-state such as pagination keeps the hold), the context-menu cross-filter, removing a cross-filter tag, filters applied from chat in useDashboardFilterSync, and filters set by an embedded host. Each one hides the banner, so Try again is no longer offered over those changes.
| import { logging } from '@apache-superset/core/utils'; | ||
|
|
||
| // Upper bound on a single attempt to load shared filter state. | ||
| export const SHARED_STATE_ATTEMPT_TIMEOUT_MS = 3000; |
There was a problem hiding this comment.
3 s is tight for a hard abort. FILTER_STATE_CACHE_CONFIG defaults to SupersetMetastoreCache, so this is a metadata DB read, and the permalink fetch is a DB read too. A backend that is uniformly slow at about 4 s fails both attempts, because each retry starts from zero.
The bug being fixed is an infinite hang, so a bound of 8 to 10 s would still fix it with far fewer false fallbacks. Alternatively, make the timeout configurable, or let the first request keep running while the second attempt starts.
There was a problem hiding this comment.
Raised to 6 s per attempt in ea87299, so a uniformly slow backend at ~4 s succeeds on the first attempt. Worst case before the fallback is 12.5 s. Also in that commit: a stored value that fails JSON.parse is classed as expired instead of retried, and the stuck isRetryingSharedState / isLoadingSharedState flags are reset at the start of each load.
- Protect the opened link's filter key instead of a one-shot "new key" flag: publishes never update that key, they create a new one, so two overlapping publishes after a fallback cannot overwrite the saved state. Hold state is reset when another dashboard loads. - Release the hold on every user-originated filter change, not only the filter bar's Apply: cross-filters (chart click, context menu, remove tag), filters applied from chat, and filters set by an embedded host. - Reset the loading and retry flags at the start of each load so a dashboard change mid-retry does not leave Try again stuck loading. - Raise the per-attempt timeout from 3s to 6s so a slow but healthy backend is not cut off twice in a row. - Treat a stored value that is not valid JSON as expired: Try again could never succeed for it. - Warn in the Share menu when a permalink is copied or emailed after a fallback, since it shares the default view. - Drop the now unused getFilterValue.
* origin/master: (303 commits) fix(dashboard): don't hang forever when saved native filter state request stalls (apache#45928) chore(deps): bump actions/setup-python from 7.0.0 to 7.1.0 in the gh-actions group (apache#45941) chore(deps): bump Kesin11/actions-timeline from 3.2.0 to 3.2.1 (apache#45942) chore(deps-dev): bump the babel group across 2 directories with 2 updates (apache#45943) chore(deps-dev): bump webpack in /docs (apache#45944) chore(deps): bump unist-util-visit from 5.1.0 to 5.2.0 in /docs (apache#45945) chore(deps): bump antd from 6.6.7 to 6.6.8 in /docs (apache#45946) chore(deps): bump antd from 6.6.7 to 6.6.8 in /superset-frontend (apache#45948) fix(dataset): do not apply the dataset timezone to DATE columns (apache#45203) chore(deps-dev): update pyathena requirement from <5,>=4.1.0 to >=4.2.1,<5 (apache#45915) chore(deps): bump flask-appbuilder from 5.2.3 to 5.3.0 (apache#45922) perf(explore): use useDeferredValue for TextControl inputs (apache#44878) chore(deps-dev): bump pandas-gbq from 0.35.2 to 0.35.3 (apache#45917) chore(deps-dev): bump pymssql from 2.4.4 to 2.4.5 (apache#45919) chore(deps): bump wtforms from 3.2.2 to 3.3.0 (apache#45920) chore(deps-dev): bump grpcio from 1.84.0 to 1.84.1 (apache#45918) chore(deps-dev): bump fonttools from 4.62.0 to 4.67.0 (apache#45921) chore(deps): bump the security group across 2 directories with 2 updates (apache#45924) fix(echarts): draw the series line style and symbol in the Plain Top/Bottom legend (apache#45648) fix(ci): grant contents: read to Python jobs that declare id-token permissions (apache#45899) ... # Conflicts: # .github/workflows/chromatic.yml # .github/workflows/superset-e2e.yml # .github/workflows/superset-frontend.yml # superset-frontend/package.json
…uest stalls (#45928) Co-authored-by: Claude Sonnet 5.5 <[email protected]> Co-authored-by: Mehmet Salih Yavuz <[email protected]>
SUMMARY
When someone opens a shared dashboard link (a link carrying a saved filter state, or a "Copy permalink" link), the page first fetches those saved filters. If that request never completes (a stalled connection, a proxy that drops the response), the dashboard sat on a blank loading spinner forever. A silent fallback to default filters would have been just as bad, since the default view can look like the shared one but show different numbers.
What this change does:
/superset/dashboard/p/<key>/links get the same timeout, retry, and banner. Embedded dashboards get the same behavior.NOT COVERED / FOLLOW-UP
?native_filters_key=and direct?permalink_key=links./superset/dashboard/p/<key>/resolves the key on the server and returns a 404 page before the SPA loads.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Waiting for the shared filters to load
Filters couldn't be loaded (stalled request): warning banner with Try again. The link in the address bar keeps its original key.
Link expired: banner without Try again
TESTING INSTRUCTIONS
Automated:
npm run test -- src/dashboard/containers/DashboardPage.test.tsx src/dashboard/util/loadSharedFilterState.test.ts src/dashboard/util/sharedFilterStateHold.test.ts src/dashboard/components/nativeFilters/FilterBar/keyValue.test.ts src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx src/dashboard/useDashboardFilterSync.test.tsx src/dashboard/components/menu/ShareMenuItems/ShareMenuItems.test.tsxManual:
?native_filters_key=<valid key>and, in browser dev tools, block or stall the/filter_state/request. You should see the loading message, then after a few seconds the dashboard with the warning banner. Unblock the request and click Try again: the saved filters apply and the banner goes away./superset/dashboard/p/<key>/permalink and by stalling/api/v1/dashboard/permalink/<key>. (Step 2 does not apply to/p/links; the server 404s before the page loads.)ADDITIONAL INFORMATION
Note: once merged, this is a good candidate to cherry-pick to the 6.0 and 6.1 release branches.
🤖 Generated with Claude Code