-
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
Fix flaky histogram when an adhoc data view is being edited #194904
Conversation
Flaky Test Runner Stats🟠 Some tests failed. - kibana-flaky-test-suite-runner#7082[❌] test/functional/apps/discover/group3/config.ts: 22/50 tests passed. |
Flaky Test Runner Stats🟠 Some tests failed. - kibana-flaky-test-suite-runner#7083[❌] test/functional/apps/discover/group3/config.ts: 23/50 tests passed. |
…data view changes
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#7091[✅] test/functional/apps/discover/group3/config.ts: 25/25 tests passed. |
}, | ||
[dataViews, stateContainer.actions, stateContainer.dataState] | ||
); | ||
|
||
const updateSavedQueryId = (newSavedQueryId: string | undefined) => { |
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 were already having the same code in our state container, time use stateContainer.actions.onDataViewEdited instead of this code
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#7101[✅] test/functional/apps/discover/group3/config.ts: 25/25 tests passed. |
💔 Build FailedFailed CI StepsHistory
To update your PR or re-run it, just comment with: cc @kertal |
- 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
stateContainer.dataState.fetch(); | ||
}, | ||
[dataViews, stateContainer.actions, stateContainer.dataState] | ||
); |
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.
seems we had this code already in our state container without using it
</DiscoverMainProvider> | ||
</DiscoverCustomizationProvider> | ||
); | ||
} | ||
// eslint-disable-next-line import/no-default-export | ||
export default DiscoverMainRoute; | ||
|
||
export function DiscoverMainLoading({ |
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.
since the loading state now is in the stateContainer, we need to have the state container in context so it's provided, therefore this change. This could be seen as first part of refactoring this file, which could use some love
setDataView(await services.dataViews.create(editedDataView.toSpec(), true)); | ||
} else { | ||
await updateAdHocDataViewId(); | ||
} | ||
loadDataViewList(); | ||
await loadDataViewList(); |
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 first thought, ha! got you flaky test monster, a missing await, however it didn't help, but it should be changed anyway
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#7105[✅] test/functional/apps/dashboard/group3/config.ts: 25/25 tests passed. |
) { | ||
// this is a workaround to make sure the new total hits value is displayed | ||
// a different value without a loading state in between would lead to be ignored by useDataState | ||
addLog( | ||
'[UnifiedHistogram] send loading to totalHits$ to make sure the new value is displayed', | ||
{ status, result } | ||
); | ||
savedSearchData$.totalHits$.next({ | ||
fetchStatus: FetchStatus.LOADING, | ||
}); |
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.
@dej611 this needs an issue as follow up to investigate
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
/ci |
💔 Build Failed
Failed CI StepsHistory
cc @kertal |
keeping this open, because i think having a general loading state in the state container could be useful, even if it's not needed now to fix the issue because of #196114 |
Summary
This fixes the following problem: 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:
It's a race condition caused by the facts that lens is treating data views a bit differently, having it's own variant of data view handling. I couldn't figure out, what causes this race condition. I therefore tried another approach. 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.Overall this approach did the job removing the flakiness on one level, and introduced flakiness on another level (That high likely was already there). CI failed not having the right total hits number. This happend because totalHits$ occionally submits 2
complete
states with different numbers (one the previous number, one the actual number), the UI is detecting state changes, to omit unnecessary updates, and therefore, sincecomplete
->complete
, no UI was updated.Overall this PR is a bit like duct tape. but duct tape that's fixing things. If accepted, there should be a follow up issue investigating the histogram state changes a bit closer.
[✅] test/functional/apps/dashboard/group3/config.ts: 25/25 tests passed. kibana-flaky-test-suite-runner#7105
Fixes #184600
Checklist