-
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] [ES|QL] Prevent redundant requests when loading Discover sessions and toggling chart visibility #206699
base: main
Are you sure you want to change the base?
Conversation
…rentSuggestionContext updates and refetches
…unt, reducing redundant requests
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.
Niiiiiiiice ❤️ !
@@ -267,18 +268,6 @@ export const useDiscoverHistogram = ({ | |||
* Data fetching | |||
*/ | |||
|
|||
const skipRefetch = useRef<boolean>(); |
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.
it's great that we can remove this logic here! 🥳
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 agree! I've always disliked this workaround and have been wanting to remove it for a while, and now I finally had a good reason 😁
@@ -289,7 +291,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { | |||
await expectSearches(type, 1, async () => { | |||
await discover.toggleChartVisibility(); | |||
}); | |||
await expectSearches(type, 3, async () => { | |||
await expectSearches(type, 2, async () => { |
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.
ha! 🎼 another requests bites the dust !
and in case this turns green: #206389
3 more requests will bite the dust
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, I wasn't even aiming to address this one originally but it was a pleasant bonus for sure! I don't think it fully resolves #206389 yet since we should still skip the documents fetch on toggle, but it's definitely related and gets us closer to that goal 👍
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 just realized #206389 is a PR and not an issue 🤦 In that case, awesome! These enhancements combined should resolve all chart visibility related fetching issues 🤘
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#7723[✅] test/functional/apps/discover/group3/config.ts: 25/25 tests passed. |
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.
@kertal Thanks for looking at it! It seems like both CI and the flaky test runner are happy with these changes, so I'm going to publish this for review now 🙂
@@ -267,18 +268,6 @@ export const useDiscoverHistogram = ({ | |||
* Data fetching | |||
*/ | |||
|
|||
const skipRefetch = useRef<boolean>(); |
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 agree! I've always disliked this workaround and have been wanting to remove it for a while, and now I finally had a good reason 😁
@@ -289,7 +291,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { | |||
await expectSearches(type, 1, async () => { | |||
await discover.toggleChartVisibility(); | |||
}); | |||
await expectSearches(type, 3, async () => { | |||
await expectSearches(type, 2, async () => { |
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, I wasn't even aiming to address this one originally but it was a pleasant bonus for sure! I don't think it fully resolves #206389 yet since we should still skip the documents fetch on toggle, but it's definitely related and gets us closer to that goal 👍
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
💚 Build Succeeded
Metrics [docs]Async chunks
History
cc @davismcphee |
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.
Code LGTM, great simplification of the code leading to omitting all redundant requests that were mentioned in #206699
So this PR is a release_note:fix
🥳
I've tested the reported extra fetches with #206699 using
https://kertal-pr-206699-fix-esql-fetches.kbndev.co/app/r/s/WIE7x
we now have a new request for fields triggered by the ES|QL editor, so the numbers changed
- ✅ When loading a ES|QL Discover session: 3 fetches
- ✅ Hiding the chart: 1 fetch, will get to 0 with [Discover] Remove redundant data fetching when hiding/showing the histogram/chart #206389
- ✅ Reload with chart: 2 fetches, expected
- ✅ Changing from Discover session with hidden chart, to one with Chart, 3 fetches, expected
- ✅ Navigating back from Dashboard, 3 fetches, expected
- ✅ Saving / opening a Discover session, 3 fetches, expected
Summary
This PR prevents redundant Discover requests in ES|QL mode for the following scenarios:
It does so by addressing several underlying state related issues that were triggering the redundant requests:
currentSuggestionContext
on Unified Histogram mount, which immediately triggered a second fetch.table
prop the same as other props which affect Lens suggestions (data view, query, columns), and deferring updates to it until result fetching completes to avoid unnecessary suggestion updates.Part of #165192.
Checklist
release_note:breaking
label should be applied in these situations.release_note:*
label is applied per the guidelines