Skip to content
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

[Lens] fix dimension panel datasource updates #161881

Merged
merged 3 commits into from
Jul 17, 2023

Conversation

mbondyra
Copy link
Contributor

@mbondyra mbondyra commented Jul 13, 2023

Summary

Fixes #161759
Fixes #161854
Fixes #161988
Fixes #161666

This bug surfaced by my change with NativeRenderer removal PR. It happens because sometimes there are two updates happening at the same time, in this case
*setState coming from optimizing middleware to update the relative timerange in a call to es

  • updating datasource.

Two updates is not a problem and works correctly for the same case for visualizations etc, but for the updateDatasourceState we break one of the fundamental rules of redux by passing non-serializable prop to action (an updater function that is then called internally with the previous state). The problem is that in the meantime the state gets updated from the previous setState call. To avoid this problem I rewrote the updateDatasourceState action to not accept updater function. To avoid these problems in the future I've also included a serializableCheck that ignores dataViews and some other properties (they contain some non-serializable data, I hope we'll take care of them in the future)

 serializableCheck: {
        ignoredActionPaths: ['lens.dataViews.indexPatterns'],
        ignoredPaths: ['lens.dataViews.indexPatterns'],
      },

I also fixed a few small issues, will leave comments in the code.

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@mbondyra mbondyra force-pushed the lens/fix_top_values_updates branch from a21164a to 7a0abaa Compare July 13, 2023 15:56
@mbondyra mbondyra marked this pull request as ready for review July 13, 2023 16:04
@mbondyra mbondyra requested a review from a team as a code owner July 13, 2023 16:04
syncCursor={config.syncCursor}
/>
</div>
<I18nProvider>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

non related to the main issue, but just saw it in the console and decided to fix

@@ -40,7 +40,7 @@ import { FieldItem } from '../common/field_item';

export type Props = Omit<
DatasourceDataPanelProps<FormBasedPrivateState>,
'core' | 'onChangeIndexPattern' | 'dragDropContext'
'core' | 'onChangeIndexPattern'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

non related to the main issue, but it's a leftover I forgot about

@@ -276,7 +276,7 @@ export function DimensionEditor(props: DimensionEditorProps) {
// changes from the static value operation (which has to be a function)
// Note: it forced a rerender at this point to avoid UI glitches in async updates (another hack upstream)
// TODO: revisit this once we get rid of updateDatasourceAsync upstream
const moveDefinetelyToStaticValueAndUpdate = (
const moveDefinitelyToStaticValueAndUpdate = (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just a typo fix :)

@mbondyra mbondyra added Team:Visualizations Visualization editors, elastic-charts and infrastructure release_note:skip Skip the PR/issue when compiling release notes Feature:Lens v8.10.0 labels Jul 13, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations @elastic/kibana-visualizations-external (Team:Visualizations)

@mbondyra mbondyra marked this pull request as draft July 13, 2023 17:00
@mbondyra mbondyra force-pushed the lens/fix_top_values_updates branch from 7a0abaa to 16f7476 Compare July 13, 2023 20:28
@mbondyra mbondyra force-pushed the lens/fix_top_values_updates branch from 75ef956 to 3844b40 Compare July 14, 2023 08:29
@@ -82,7 +82,6 @@ export interface ReferenceEditorProps {
labelAppend?: EuiFormRowProps['labelAppend'];
isFullscreen: boolean;
toggleFullscreen: () => void;
setIsCloseable: (isCloseable: boolean) => void;
Copy link
Contributor Author

@mbondyra mbondyra Jul 14, 2023

Choose a reason for hiding this comment

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

I removed all code associated with it because seems like this is not needed anymore... I am not sure what changed it but it was introduced 2 years ago with formula editor PR (#99297). The comment says it solves ' Popover steals focus from text input, and doesn't close when clicking the monaco editor. Needs an alternative design', but I couldn't reproduce it and tested quite extensively.
I even checked 7.14 version where formula was introduced and the behavior is the same.

@mbondyra mbondyra marked this pull request as ready for review July 14, 2023 08:42
Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

@mbondyra this looks fantastic and I think it solves all the bugs that were created.
@dej611 can you also take a look?

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #59 / alerting api integration security and spaces enabled - Group 2 Alerts legacy alerts alerts "after all" hook in "alerts"
  • [job] [logs] FTR Configs #59 / alerting api integration security and spaces enabled - Group 2 Alerts legacy alerts alerts "before all" hook in "alerts"
  • [job] [logs] FTR Configs #10 / EPM Endpoints EPM - get Installed Packages Allows the fetching of installed packages

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 1.3MB 1.3MB -646.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
expressionHeatmap 14.7KB 14.7KB +43.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

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

Tested locally with Safari 👍

@mbondyra mbondyra merged commit 9f67549 into elastic:main Jul 17, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jul 17, 2023
@mbondyra mbondyra deleted the lens/fix_top_values_updates branch July 17, 2023 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment