-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Discover] Add internalState loading function preventing data view id change related race conditions #199419
The head ref may contain hidden characters: "discover-unskip-_lens_vis\u00B7ts"
Conversation
…data view changes
- this deserves to be a first level function - we can exchange underlying implementation if needed
- this deserves to be a first level function - we can exchange underlying implementation if needed
/ci |
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#7353[✅] test/functional/apps/discover/group3/config.ts: 25/25 tests passed. |
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
stateContainer={stateContainer} | ||
hideNavMenuItems={showNoDataPage || loading} | ||
/> | ||
{loading && !showNoDataPage ? <LoadingIndicator /> : mainContent} |
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.
Should not we continue using loadingIndicator
instead of <LoadingIndicator />
?
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.
yes, this makes sense, it appears there were more changes, than I noticed since I started to fix this in another PR 👍
const onDataViewEdited = async (editedDataView: DataView) => { | ||
setIsLoading(true); |
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.
I wonder if isDataViewLoading
should be toggled too.
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.
For me it appears we just use isDataViewLoading
in
kibana/src/plugins/discover/public/application/main/components/layout/discover_documents.tsx
Line 169 in 8545b9c
useInternalStateSelector((state) => state.isDataViewLoading) && !isEsqlMode; |
and
kibana/src/plugins/discover/public/application/main/components/layout/discover_layout.tsx
Lines 104 to 107 in 7369442
const [dataView, dataViewLoading] = useInternalStateSelector((state) => [ | |
state.dataView!, | |
state.isDataViewLoading, | |
]); |
We set it to true when a data view is being changes.
With the new isLoading
prop those components should not be displayed. So I'd say it's not necessary ... one think I wonder, would it make sense to combing all those loading states into one prop? one that can be used to get information about general loading state, data view loading state, data loading state ... just load thinking
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.
Yeah, I was also wondering if we could use isDataViewLoading
instead of introducing a new isLoading
.
Editing a data view might be considered as "loading" its new state.
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.
@@ -110,8 +110,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { | |||
return seriesType; | |||
} | |||
|
|||
// FLAKY: https://github.com/elastic/kibana/issues/184600 | |||
describe.skip('discover lens vis', function () { | |||
describe('discover lens vis', function () { |
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.
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.
We might need to load data views right after a new one is created and before it gets replaces in the app state/URL:
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.
there's some really dark magic here, that even when investigating this caused my IDE to freeze, so just before the last meeting of my day, I'm thinking that the cleanup of adhoc data views that were changed because of a spec change, should be triggered later on:
kibana/src/plugins/discover/public/application/main/state_management/discover_state.ts
Line 430 in 7f1503e
services.dataViews.clearInstanceCache(edited); |
because then the previous data view would still be available, wouldn't do any harm, and be removed after the data fetching was triggered
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.
clearly broken here, looking for a simpler solution, so far I couldn't this seems to resolve this issue locally, let's see what flaky test runner says: #199982
💚 Build Succeeded
Metrics [docs]Async chunks
History
cc @kertal |
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
Closing this for a different approach |
Summary
There's an occasional race condition, when an adhoc data view is changed, its id is also regenerated, technically we create a new data replacing the previous one. Therefore we guarantee each ad hoc data view id is uniqe when its spec changed. Otherwise we can't prevent duplicates. Lens, being used by the UnifiedHistogram, occasionally didn't know about the new id, having a list of data views with just the old id, and this led to the following error:
This is caused by a race condition I assumed it would be fixed in #196114. But it started to fail again. So this PR makes should make sure, it can't fail again.
It's introducing a new variable
isLoading
on Discover's internal state, replacing theisLoading
ondiscover_main_route
. While the previous implementation was just available indiscover_main_route
, now other parts of Discover main can set Discover to it's loading state on the main route level. This cleans up any local UI state, so Discover is loaded in afresh
state which is beneficial for complex operation like the described id change of an underlying data structure like the data view.Ideally we should aim to fix the race condition, but this area of code should be focused to be refacored soon, and having a way to switch Discover to its intial loading state can for sure be useful for other complex changes, that's why I considered to move forward here
Fixes #184600
Checklist