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

[Custom threshold] Preview chart goes to infinite loading #202266

Closed
maryam-saeidi opened this issue Nov 29, 2024 · 4 comments · Fixed by #203150
Closed

[Custom threshold] Preview chart goes to infinite loading #202266

maryam-saeidi opened this issue Nov 29, 2024 · 4 comments · Fixed by #203150
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Team:obs-ux-management Observability Management User Experience Team

Comments

@maryam-saeidi
Copy link
Member

maryam-saeidi commented Nov 29, 2024

🐛 Summary

As shown below, the preview chart in the custom threshold flyout goes to infinite loading:

Screen.Recording.2024-11-29.at.11.01.46.mov

This issue impacts:

  • Rule flyout
    • Custom threshold
    • Metric threshold
  • Alert details page
    • Custom threshold
    • Metric threshold
@maryam-saeidi maryam-saeidi added bug Fixes for quality problems that affect the customer experience Team:obs-ux-management Observability Management User Experience Team labels Nov 29, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@dej611 dej611 self-assigned this Nov 29, 2024
@maryam-saeidi
Copy link
Member Author

Using git bisect led us to this PR: #186642

@jasonrhodes
Copy link
Member

Is this happening all the time in all environments, since that mentioned PR merged last week? If so, I think this is a pretty severe bug we should fix ASAP especially for serverless...

@maryam-saeidi
Copy link
Member Author

maryam-saeidi commented Dec 3, 2024

Yes, it is happening in all environments, AFAIK. @dej611 is working on a fix: #202321

I also noticed it will send a lot of telemetry events, which I am not sure why 🤔
It is related to this event: eventName: lens_chart_es_request_totals

Image

@dej611 dej611 closed this as completed in d4194ba Dec 11, 2024
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Dec 11, 2024
…stic#203150)

## Summary

Fixes elastic#202266

This PR fixes the underline rerendering issue at the `useSearchApi` hook
level, so any embeddable component who uses this hook would benefit from
the fix.

Ideally the props passed to the Lens component should be memoized, but
this assumption would break many integrations as the previous embeddable
component did take care of filtering duplicates.
To test this:
* Go to `Observability > Alerts > Manage rules` and `Add Rule`, pick the
`Custom threshold` option and verify the infinite reload does not happen

Once fixed this, another problem bubbled up with the brushing use case:
when brushing a chart the chart was always one time range step behind.
The other bug was due to the `fetch$(api)` function propagating a stale
`data` search context who the Lens embeddable was relying on.
To solve this other problem the following changes have been applied:
* read the `searchSessionId` from the `api` directly (used for
`autoRefresh`)
* make sure to test the `Refresh` feature with both relative and
absolute time ranges
* read the `search context` from the `parentApi` directly if implements
the `unifiedSearch` API
* to test this, brush and check that the final time range matches the
correct time range

**Note**: the fundamental issue for the latter is `fetch$` not emitting
the up-to-date `data` when the parentApi search context updates. The
retrieved `data` is stale and one step behind, so it is not reliable. cc
@elastic/kibana-presentation

As @ThomThomson noticed in his test failure investigation another issue
was found in this PR due to the wrong handling of the searchSessionId
within the Observability page (for more details see [his
analysis](elastic#203150 (comment))).
@markov00 and @crespocarlos helped risolve this problem with some
additional changes on the Observability side of things: this will lead
to some extra searchSessionId to be created, which will be eventually
solved by Observability team [shortly moving away from the
`searchSessionId`
mechanism](elastic#203412)

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Marco Vettorello <[email protected]>
Co-authored-by: Carlos Crespo <[email protected]>
(cherry picked from commit d4194ba)
kibanamachine added a commit that referenced this issue Dec 11, 2024
#203150) (#203818)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Embeddable] Avoid rerendering loop due to search context reload
(#203150)](#203150)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Marco
Liberati","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-11T15:03:36Z","message":"[Embeddable]
Avoid rerendering loop due to search context reload (#203150)\n\n##
Summary\r\n\r\nFixes #202266\r\n\r\nThis PR fixes the underline
rerendering issue at the `useSearchApi` hook\r\nlevel, so any embeddable
component who uses this hook would benefit from\r\nthe
fix.\r\n\r\nIdeally the props passed to the Lens component should be
memoized, but\r\nthis assumption would break many integrations as the
previous embeddable\r\ncomponent did take care of filtering
duplicates.\r\nTo test this:\r\n* Go to `Observability > Alerts > Manage
rules` and `Add Rule`, pick the\r\n`Custom threshold` option and verify
the infinite reload does not happen\r\n\r\nOnce fixed this, another
problem bubbled up with the brushing use case:\r\nwhen brushing a chart
the chart was always one time range step behind.\r\nThe other bug was
due to the `fetch$(api)` function propagating a stale\r\n`data` search
context who the Lens embeddable was relying on.\r\nTo solve this other
problem the following changes have been applied:\r\n* read the
`searchSessionId` from the `api` directly (used
for\r\n`autoRefresh`)\r\n* make sure to test the `Refresh` feature with
both relative and\r\nabsolute time ranges\r\n* read the `search context`
from the `parentApi` directly if implements\r\nthe `unifiedSearch`
API\r\n* to test this, brush and check that the final time range matches
the\r\ncorrect time range\r\n\r\n**Note**: the fundamental issue for the
latter is `fetch# Backport

This will backport the following commits from `main` to `8.x`:
- [[Embeddable] Avoid rerendering loop due to search context reload
(#203150)](#203150)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT not emitting\r\nthe up-to-date `data` when the parentApi
search context updates. The\r\nretrieved `data` is stale and one step
behind, so it is not reliable.
cc\r\n@elastic/kibana-presentation\r\n\r\nAs @ThomThomson noticed in his
test failure investigation another issue\r\nwas found in this PR due to
the wrong handling of the searchSessionId\r\nwithin the Observability
page (for more details see
[his\r\nanalysis](https://github.com/elastic/kibana/pull/203150#issuecomment-2524080129)).\r\n@markov00
and @crespocarlos helped risolve this problem with some\r\nadditional
changes on the Observability side of things: this will lead\r\nto some
extra searchSessionId to be created, which will be eventually\r\nsolved
by Observability team [shortly moving away from
the\r\n`searchSessionId`\r\nmechanism](https://github.com/elastic/kibana/issues/203412)\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Vettorello
<[email protected]>\r\nCo-authored-by: Carlos Crespo
<[email protected]>","sha":"d4194ba5eb5a72960dad00cf956d9ea6e31219e0","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Presentation","v9.0.0","backport:prev-minor","Feature:Embeddables","ci:project-deploy-observability","Team:obs-ux-management"],"title":"[Embeddable]
Avoid rerendering loop due to search context
reload","number":203150,"url":"https://github.com/elastic/kibana/pull/203150","mergeCommit":{"message":"[Embeddable]
Avoid rerendering loop due to search context reload (#203150)\n\n##
Summary\r\n\r\nFixes #202266\r\n\r\nThis PR fixes the underline
rerendering issue at the `useSearchApi` hook\r\nlevel, so any embeddable
component who uses this hook would benefit from\r\nthe
fix.\r\n\r\nIdeally the props passed to the Lens component should be
memoized, but\r\nthis assumption would break many integrations as the
previous embeddable\r\ncomponent did take care of filtering
duplicates.\r\nTo test this:\r\n* Go to `Observability > Alerts > Manage
rules` and `Add Rule`, pick the\r\n`Custom threshold` option and verify
the infinite reload does not happen\r\n\r\nOnce fixed this, another
problem bubbled up with the brushing use case:\r\nwhen brushing a chart
the chart was always one time range step behind.\r\nThe other bug was
due to the `fetch$(api)` function propagating a stale\r\n`data` search
context who the Lens embeddable was relying on.\r\nTo solve this other
problem the following changes have been applied:\r\n* read the
`searchSessionId` from the `api` directly (used
for\r\n`autoRefresh`)\r\n* make sure to test the `Refresh` feature with
both relative and\r\nabsolute time ranges\r\n* read the `search context`
from the `parentApi` directly if implements\r\nthe `unifiedSearch`
API\r\n* to test this, brush and check that the final time range matches
the\r\ncorrect time range\r\n\r\n**Note**: the fundamental issue for the
latter is `fetch# Backport

This will backport the following commits from `main` to `8.x`:
- [[Embeddable] Avoid rerendering loop due to search context reload
(#203150)](#203150)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT not emitting\r\nthe up-to-date `data` when the parentApi
search context updates. The\r\nretrieved `data` is stale and one step
behind, so it is not reliable.
cc\r\n@elastic/kibana-presentation\r\n\r\nAs @ThomThomson noticed in his
test failure investigation another issue\r\nwas found in this PR due to
the wrong handling of the searchSessionId\r\nwithin the Observability
page (for more details see
[his\r\nanalysis](https://github.com/elastic/kibana/pull/203150#issuecomment-2524080129)).\r\n@markov00
and @crespocarlos helped risolve this problem with some\r\nadditional
changes on the Observability side of things: this will lead\r\nto some
extra searchSessionId to be created, which will be eventually\r\nsolved
by Observability team [shortly moving away from
the\r\n`searchSessionId`\r\nmechanism](https://github.com/elastic/kibana/issues/203412)\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Vettorello
<[email protected]>\r\nCo-authored-by: Carlos Crespo
<[email protected]>","sha":"d4194ba5eb5a72960dad00cf956d9ea6e31219e0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203150","number":203150,"mergeCommit":{"message":"[Embeddable]
Avoid rerendering loop due to search context reload (#203150)\n\n##
Summary\r\n\r\nFixes #202266\r\n\r\nThis PR fixes the underline
rerendering issue at the `useSearchApi` hook\r\nlevel, so any embeddable
component who uses this hook would benefit from\r\nthe
fix.\r\n\r\nIdeally the props passed to the Lens component should be
memoized, but\r\nthis assumption would break many integrations as the
previous embeddable\r\ncomponent did take care of filtering
duplicates.\r\nTo test this:\r\n* Go to `Observability > Alerts > Manage
rules` and `Add Rule`, pick the\r\n`Custom threshold` option and verify
the infinite reload does not happen\r\n\r\nOnce fixed this, another
problem bubbled up with the brushing use case:\r\nwhen brushing a chart
the chart was always one time range step behind.\r\nThe other bug was
due to the `fetch$(api)` function propagating a stale\r\n`data` search
context who the Lens embeddable was relying on.\r\nTo solve this other
problem the following changes have been applied:\r\n* read the
`searchSessionId` from the `api` directly (used
for\r\n`autoRefresh`)\r\n* make sure to test the `Refresh` feature with
both relative and\r\nabsolute time ranges\r\n* read the `search context`
from the `parentApi` directly if implements\r\nthe `unifiedSearch`
API\r\n* to test this, brush and check that the final time range matches
the\r\ncorrect time range\r\n\r\n**Note**: the fundamental issue for the
latter is `fetch# Backport

This will backport the following commits from `main` to `8.x`:
- [[Embeddable] Avoid rerendering loop due to search context reload
(#203150)](#203150)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT not emitting\r\nthe up-to-date `data` when the parentApi
search context updates. The\r\nretrieved `data` is stale and one step
behind, so it is not reliable.
cc\r\n@elastic/kibana-presentation\r\n\r\nAs @ThomThomson noticed in his
test failure investigation another issue\r\nwas found in this PR due to
the wrong handling of the searchSessionId\r\nwithin the Observability
page (for more details see
[his\r\nanalysis](https://github.com/elastic/kibana/pull/203150#issuecomment-2524080129)).\r\n@markov00
and @crespocarlos helped risolve this problem with some\r\nadditional
changes on the Observability side of things: this will lead\r\nto some
extra searchSessionId to be created, which will be eventually\r\nsolved
by Observability team [shortly moving away from
the\r\n`searchSessionId`\r\nmechanism](https://github.com/elastic/kibana/issues/203412)\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Vettorello
<[email protected]>\r\nCo-authored-by: Carlos Crespo
<[email protected]>","sha":"d4194ba5eb5a72960dad00cf956d9ea6e31219e0"}}]}]
BACKPORT-->

Co-authored-by: Marco Liberati <[email protected]>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this issue Dec 12, 2024
…stic#203150)

## Summary

Fixes elastic#202266

This PR fixes the underline rerendering issue at the `useSearchApi` hook
level, so any embeddable component who uses this hook would benefit from
the fix.

Ideally the props passed to the Lens component should be memoized, but
this assumption would break many integrations as the previous embeddable
component did take care of filtering duplicates.
To test this:
* Go to `Observability > Alerts > Manage rules` and `Add Rule`, pick the
`Custom threshold` option and verify the infinite reload does not happen

Once fixed this, another problem bubbled up with the brushing use case:
when brushing a chart the chart was always one time range step behind.
The other bug was due to the `fetch$(api)` function propagating a stale
`data` search context who the Lens embeddable was relying on.
To solve this other problem the following changes have been applied:
* read the `searchSessionId` from the `api` directly (used for
`autoRefresh`)
* make sure to test the `Refresh` feature with both relative and
absolute time ranges
* read the `search context` from the `parentApi` directly if implements
the `unifiedSearch` API
* to test this, brush and check that the final time range matches the
correct time range

**Note**: the fundamental issue for the latter is `fetch$` not emitting
the up-to-date `data` when the parentApi search context updates. The
retrieved `data` is stale and one step behind, so it is not reliable. cc
@elastic/kibana-presentation

As @ThomThomson noticed in his test failure investigation another issue
was found in this PR due to the wrong handling of the searchSessionId
within the Observability page (for more details see [his
analysis](elastic#203150 (comment))).
@markov00 and @crespocarlos helped risolve this problem with some
additional changes on the Observability side of things: this will lead
to some extra searchSessionId to be created, which will be eventually
solved by Observability team [shortly moving away from the
`searchSessionId`
mechanism](elastic#203412)

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Marco Vettorello <[email protected]>
Co-authored-by: Carlos Crespo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Team:obs-ux-management Observability Management User Experience Team
Projects
None yet
4 participants